Bug Tracker

Modify

Ticket #6478 (closed bug: wontfix)

Opened 3 years ago

Last modified 3 years ago

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

Description

This line crashes IE6 and IE7 under jQuery 1.4.2:

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

Change History

comment:1 Changed 3 years ago by seasoup

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;

}

comment:2 Changed 3 years ago by dmethvin

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

comment:3 Changed 3 years ago by dmethvin

  • Summary changed from attr crashes IE6 and IE7 in 1.4.2 to $("<li></li>").attr("value", 42) crashes IE6 and IE7 in 1.4.2

comment:4 Changed 3 years ago by addyosmani

  • Priority set to undecided
  • Status changed from new to closed
  • Resolution set to invalid

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.

comment:5 Changed 3 years ago by miketaylr

  • Status changed from closed to reopened
  • Resolution invalid deleted

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

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

comment:6 Changed 3 years ago by dmethvin

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.

comment:7 Changed 3 years ago by snover

  • Status changed from reopened to closed
  • Resolution set to wontfix

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">').

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.