Bug Tracker

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#4230 closed bug (fixed)

$('<link/>').attr crashes IE8rc1

Reported by: yoursunny Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:


I'm running IE8rc1 (en-us) on Windows Server 2003 (zh-cn), and I'm using jQuery version 1.3.2.

I'm inserting a stylesheet into the HTML page, but iexplore.exe Tab-process crashes every time. The code is in the attachment.

After reading through the source code of jQuery, I found that jQuery is injecting the <link/> tag into a <div/>, which is not allowed by W3C standards. <link/> should only appear in <head/>, but <div/> appears in <body/>. It seems that jQuery's illegal operation causes IE8rc1 to crash when attr() is called.

Please also see the related post in IE newsgroup: http://tinyurl.com/aq7zyu , and the bug in IE's tracker: http://tinyurl.com/bbh5ks .

Attachments (2)

DOM2-IEcrash.htm (694 bytes) - added by yoursunny 14 years ago.
jQuery-IEcrash.htm (649 bytes) - added by yoursunny 14 years ago.

Download all attachments as: .zip

Change History (5)

Changed 14 years ago by yoursunny

Attachment: DOM2-IEcrash.htm added

Changed 14 years ago by yoursunny

Attachment: jQuery-IEcrash.htm added

comment:1 Changed 14 years ago by yoursunny

The jQuery code causing IE to crash is: $('<link rel="stylesheet" type="text/css"/>').attr('href','http://css.cn.msn.com/c/green14.css');

It is equivalent to the DOM2 code in DOM2-IEcrash.htm

comment:2 Changed 14 years ago by dmethvin

Resolution: fixed
Status: newclosed

I've updated the documentation to clarify that the HTML is parsed using a div, and therefore can't contain elements that are not valid in a div.


Let's hope that IE8 fixes the crash with the released version.

comment:3 Changed 14 years ago by dmethvin

Also, if you create the element using $("<link />") and add the attrs afterwards, that may work with IE8 because that case uses document.createElement.

Note: See TracTickets for help on using tickets.