Bug 22481 - Please consider supporting "document.myForm" access to elements by name in XHTML
Summary: Please consider supporting "document.myForm" access to elements by name in XHTML
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Enhancement
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-25 01:30 PST by Raghu
Modified: 2011-09-15 11:30 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Raghu 2008-11-25 01:30:17 PST
Accessing the form elements through "document.myform-id" doesn't work in XHTML files. But if i try the same mechanism, in HTML file, it works fine. 
Since I am using XHTML 1.0 transitional, it should work with XHTML file as well.


In XHTML content, the JSCore throws TypeError, saying "document.myform-id" is undefined.

I have tested this on Safari with latest nightly and Webkit/Gtk+ with latest nightly.

[Note: The JS engine in Chrome supports this way of accessing forms.]


See the test page below:
---------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC 
"-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="application/xhtml+xml;
charset=UTF-8"/>
<title>Form access </title>
</head>
<body
style="background-color:white;border-left:0px;border-top:0px;overflow:hidden;"
>
<form id="myform" method="POST" action="about:blank">
<input type="hidden" id="name" value=""></input>
</form>

<script type="text/javascript">
document.myform.name.value="test";
document.myform.setAttribute("action","about:blank");
document.myform.submit();
</script>
</body>
</html>
----------------------------------------------------------
Comment 1 Alexey Proskuryakov 2008-11-25 06:16:48 PST
Who on Chromium team would know whether this behavior is intentional in Chrome, or just a bug?
Comment 2 Raghu 2008-11-25 07:53:14 PST
ap, I am sorry ..
I just checked in Chrome .. It doesn't work.. 
It throws same TypeError.
But the same page, when served as HTML works fine in webkit.
Isn't it required to behave same as in HTML?. Coz., the XHTML that I am using is 1.0 transitional.


(In reply to comment #1)
> Who on Chromium team would know whether this behavior is intentional in Chrome,
> or just a bug?
> 
Comment 3 Alexey Proskuryakov 2008-11-25 08:44:36 PST
Are sure sure this works anywhere? Your example in bug 22378 used name, not id.
Comment 4 Raghu 2008-11-25 22:46:08 PST
Right.. using 'name' works , Not by ID.

(In reply to comment #3)
> Are sure sure this works anywhere? Your example in bug 22378 used name, not id.

Comment 5 Alexey Proskuryakov 2011-09-15 11:30:51 PDT
Per discussion above, it doesn't appear that there is any bug or inconsistency. Safari, Chrome and Firefox behave the same on the above test case, whether it's served as HTML or as XHTML.