Skip to main content

Bug Tracker

Side navigation

#6478 closed bug (wontfix)

Opened April 23, 2010 10:52PM UTC

Closed October 03, 2010 10:46PM UTC

$("<li></li>").attr("value", 42) crashes IE6 and IE7 in 1.4.2

Reported by: bluescrubbie Owned by:
Priority: undecided Milestone: 1.4.3
Component: attributes Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:
Description

This line crashes IE6 and IE7 under jQuery 1.4.2:

$("<li></li>").attr("value", 42);

Attachments (0)
Change History (7)

Changed April 26, 2010 09:28PM UTC by seasoup comment:1

Seems to be crashing at

elem[ name ] = value;

in the code below, in IE6 at least:

If applicable, access the attribute via the DOM 0 way

if ( name in elem && notxml && !special ) {

if ( set ) {

We can't allow the type property to be changed (since it causes problems in IE)

if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {

jQuery.error( "type property can't be changed" );

}

elem[ name ] = value;

}

Changed June 18, 2010 02:26AM UTC by dmethvin comment:2

Does this crash as well? (I don't have IE6 handy.)

  var e = document.createElement("li");
  e.value = 42;

Note that the value property of an li element is deprecated:

http://msdn.microsoft.com/en-us/library/ms535124(v=VS.85).aspx

Changed June 18, 2010 02:27AM UTC by dmethvin comment:3

summary: attr crashes IE6 and IE7 in 1.4.2$("<li></li>").attr("value", 42) crashes IE6 and IE7 in 1.4.2

Changed October 02, 2010 07:30PM UTC by addyosmani comment:4

priority: → undecided
resolution: → invalid
status: newclosed

dmethvin's comment that the property value is deprecated is correct.

When testing the above using vanilla JavaScript the exact same error (browser terminating unexpectedly) is incurred as when one uses jQuery to attempt to achieve the same result.

Given that this appears to be more of a vendor browser issue and not a jQuery core one, I am flagging as invalid due to the deprecation factor.

Changed October 03, 2010 10:02PM UTC by miketaylr comment:5

resolution: invalid
status: closedreopened

@value is not deprecated in HTML5. This should be fixed.

http://www.w3.org/TR/html5/grouping-content.html#the-li-element

Changed October 03, 2010 10:40PM UTC by dmethvin comment:6

I am not sure why I said it was deprecated, the link I gave doesn't say that so maybe it was changed recently.

The problem remains, however. We can't get Microsoft to change IE6 or IE7. So how should it be "fixed" reasonably? If we silently avoid setting

value
on IE6/7 then it will make debugging difficult. My recommendation would be wontfix for the code and simply document this but other solutions are welcome.

Changed October 03, 2010 10:46PM UTC by snover comment:7

resolution: → wontfix
status: reopenedclosed

The crash only occurs if the element is not attached to the document and the attribute is set.

Workaround 1: Set the attribute after appending the element to the document.

Workaround 2: Set the attribute in the string directly, e.g. $('<li value="2">').