Bug Tracker

Ticket #12132 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

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

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.

Change History

comment:1 Changed 2 years ago by elijahmanor

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.

comment:2 Changed 2 years ago by dmethvin

  • Priority changed from undecided to blocker
  • Status changed from new to open
  • Component changed from unfiled to manipulation
  • Milestone changed from None to 1.8

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

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

comment:3 Changed 2 years ago by dmethvin

  • Owner set to dmethvin
  • Status changed from open to assigned

comment:4 Changed 2 years ago by Elijah Manor

  • Status changed from assigned to closed
  • Resolution set to fixed

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

Changeset: 077987876bbd01b8b48a72b3573694fafaa44d39

Note: See TracTickets for help on using tickets.