Skip to main content

Bug Tracker

Side navigation

#12132 closed bug (fixed)

Opened July 24, 2012 01:42AM UTC

Closed July 24, 2012 06:53PM UTC

IE10 bug when cloning an object element without a parentNode

Reported by: elijahmanor Owned by: dmethvin
Priority: blocker Milestone: 1.8
Component: manipulation Version: git
Keywords: Cc:
Blocked by: Blocking:
Description

Only one of all the existing unit tests in jQuery fails when ran against IE10 http://cl.ly/image/0T1H3m1a0v1H

It is the following test in the manipulation module that is failing...

test("html() object element #10324", function() { ... });

Not too long ago a similar fix was added to workaround an issue with IE9 https://github.com/jquery/jquery/commit/2795a8390c1986200bf4e00158dbf3ad2da8d898

As it turns out IE10 throws a NoModificationAllowedError when setting the outerHTML of an element with a null parentNode. This behavior is different than IE9 and previous versions. I looked into the HTML5 spec and it says that the NO_MODIFICATION_ALLOWED_ERR error should be thrown if the parent is a Document http://html5.org/specs/dom-parsing.html#dom-element-outerhtml My guess is that IE10 took that new spec and took it a little further.

Attachments (0)
Change History (4)

Changed July 24, 2012 01:44AM UTC by elijahmanor comment:1

I had made a Pull Request to address this issue https://github.com/jquery/jquery/pull/870

As mentioned in the pull request...

In order to get around the issue, I am checking if the destination node has a parentNode before assigning to the outerHTML property. With this change IE10/9/8/7/6 all pass the current unit tests along with latest FF and Chrome releases. The code inside the cloneFixAttributes function that I modified is really to fix IE in the first place, so other browsers aren't really affected too much.

I initially also added a check to verify that the nodeType was not 9 (Node.DOCUMENT_NODE), but the code block that I changed only pertains to the object nodeName and I can't think of a use case where it's parentNode would ever be a document, so I think it is safe to leave out this check and leave the fix as terse as possible to save some bytes ;)

I may have been overgenerous with comments in this fix, but since it was an odd browser change I thought it might be helpful as I see other browser work arounds have similar comments.

Changed July 24, 2012 01:58PM UTC by dmethvin comment:2

component: unfiledmanipulation
milestone: None1.8
priority: undecidedblocker
status: newopen

Confirmed. http://i.imgur.com/284Ld.png

Also looking into the long-async ready fail but that may be spurious.

Changed July 24, 2012 02:03PM UTC by dmethvin comment:3

owner: → dmethvin
status: openassigned

Changed July 24, 2012 06:53PM UTC by Elijah Manor comment:4

resolution: → fixed
status: assignedclosed

Fix #12132. IE10 dislikes detached object elements. Close gh-870.

Changeset: 077987876bbd01b8b48a72b3573694fafaa44d39