Bug Tracker

Modify

Ticket #7600 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

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:
Blocking: Blocked by:

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

comment:1 Changed 3 years ago by rwaldron

  • Owner set to lowell@…
  • Status changed from new to pending

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 3 years ago by rwaldron

  • Status changed from pending to closed
  • Resolution set to invalid

"<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 3 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 3 years ago by lowellnelson

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.