Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#7600 closed bug (invalid)

html( htmlString ) mangles OPTION value if the value is not delimited

Reported by: lowell@… Owned by: lowell@…
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.

Change History (4)

comment:1 Changed 9 years ago by Rick Waldron

Owner: set to lowell@…
Status: newpending

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!

comment:2 Changed 9 years ago by Rick Waldron

Resolution: invalid
Status: pendingclosed

"<option value=slash/>slash/</option>" isn't valid markup.

Take a look at this test case, with valid markup:

http://jsfiddle.net/rwaldron/KKRMd/1/

comment:3 Changed 9 years ago by jitter

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

comment:4 Changed 9 years ago by lowellnelson

Thank you for your good help, particularly your mentioning W3C 3.2.2. Lowell.

Note: See TracTickets for help on using tickets.