Side navigation
#7600 closed bug (invalid)
Opened November 22, 2010 10:55PM UTC
Closed November 22, 2010 11:10PM UTC
Last modified November 22, 2010 11:37PM UTC
html( htmlString ) mangles OPTION value if the value is not delimited
Reported by: | lowell@netdocuments.com | Owned by: | lowell@netdocuments.com |
---|---|---|---|
Priority: | undecided | Milestone: | 1.5 |
Component: | unfiled | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I am seeing a bug when I set the HTML contents of a tag with the jQuery .html( htmlString ) method when htmlString ends with a forward slash.
Steps to DUP. Assuming the existence of a DIV tag whose id attribute is "ndDiv", I set its HTML contents and then read what I wrote with an alert:
var html; html = '<option value="slash/">slash/</option>'; // ok $('#ndDiv').html(html); alert( $('#ndDiv').html() ); html = '<option value=slash/>slash/</option>'; // bad $('#ndDiv').html(html); alert( $('#ndDiv').html() );
The behavior is the same if the html string begins with '<select>' and ends with '</select>".
I am getting the latter ("bad") instance of the option string from the jQuery transform plugin.
I don’t know if the bug is in jQuery Transform or in jQuery core.
If the HTML specification requires that attribute values be surrounded by quotes, then the bug is in jQuery Transform, and jQuery core is just responding to bad input.
If the HTML specification does not require that attribute values be surrounded by quotes, then the bug is in jQuery core.
I am reporting this bug on the jQuery Plugins site as well.
Please advise. Thank you.
Attachments (0)
Change History (4)
Changed November 22, 2010 11:03PM UTC by comment:1
owner: | → lowell@netdocuments.com |
---|---|
status: | new → pending |
Changed November 22, 2010 11:10PM UTC by comment:2
resolution: | → invalid |
---|---|
status: | pending → closed |
"<option value=slash/>slash/</option>" isn't valid markup.
Take a look at this test case, with valid markup:
Changed November 22, 2010 11:29PM UTC by comment:3
As already stated by rwaldron above. The second html string is simply invalid.
In XHTML the attribute value needs to be always quoted. In HTML 4.01 leaving away the quotes is only possible in certain cases when the attribute value only consists of a certain character subset and /
isn't in that subset HTML 4.01 Attributes
Changed November 22, 2010 11:37PM UTC by comment:4
Thank you for your good help, particularly your mentioning W3C 3.2.2. Lowell.
Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!
Additionally, test against the jQuery 0 GIT version to ensure the issue still exists. Be Excellent to eachother!