Bug 22481
| Summary: | Please consider supporting "document.myForm" access to elements by name in XHTML | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Raghu <raghavendra.deshpande> |
| Component: | WebCore JavaScript | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED INVALID | ||
| Severity: | Enhancement | CC: | ap, eric, jkjiang, raghavendra.deshpande |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | All | ||
| OS: | All | ||
Raghu
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>
----------------------------------------------------------
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Alexey Proskuryakov
Who on Chromium team would know whether this behavior is intentional in Chrome, or just a bug?
Raghu
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?
>
Alexey Proskuryakov
Are sure sure this works anywhere? Your example in bug 22378 used name, not id.
Raghu
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.
Alexey Proskuryakov
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.