Bug Tracker

Ticket #8080 (closed bug: duplicate)

Opened 4 years ago

Last modified 4 years ago

NoCloneEvent flag in jQuery.support is not correct on IE9.

Reported by: anonymous Owned by:
Priority: high Milestone: 1.5.1
Component: manipulation Version: 1.5rc1
Keywords: Cc:
Blocking: Blocked by:

Description

I try to use the following code to create a small DOM element.

$('<span>test</span>');

But I got error on IE9(Post Beta Build 8027) jQuery will cache this DOM in somewhere and clone the cached DOM object by calling the following method

 jQuery.extend({
        clone: function (elem, dataAndEvents, deepDataAndEvents) {
            var clone = elem.cloneNode(true),
				srcElements,
				destElements,
				i;

            if (!jQuery.support.noCloneEvent && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem)) {
                // IE copies events bound via attachEvent when using cloneNode.
                // Calling detachEvent on the clone will also remove the events
                // from the original. In order to get around this, we use some
                // proprietary methods to clear the events. Thanks to MooTools
                // guys for this hotness.

                // Using Sizzle here is crazy slow, so we use getElementsByTagName
                // instead
                srcElements = elem.getElementsByTagName("*");
                destElements = clone.getElementsByTagName("*");

I found that jQuery.support.noCloneEvent object is invalid when compare with other browser that is the cause of error(It try to execute the following but elem has not method name getElementsByTagName).

srcElements = elem.getElementsByTagName("*");

After I trace all related code, I found that elem object is created by createDocumentFragment method in document object. The error code equals with my below code that does not work both on IE9 and Chrome 8.

document.createDocumentFragment().getElementsByTagName("*");

I just create JsFiddle for testing this error.

 http://jsfiddle.net/Soul_Master/ZE82B/1/

But it will works correctly because it forces IE9 to render with "EmulateIE7" mode so you should directly call real web page or use my following link.

 http://fiddle.jshell.net/Soul_Master/ZE82B/1/show/

Change History

comment:1 Changed 4 years ago by anonymous

It will work correctly if HTML string is longer than max cache size.

 http://jsfiddle.net/Soul_Master/mks7P/4/

Direct Link:  http://fiddle.jshell.net/Soul_Master/mks7P/4/show/

comment:2 Changed 4 years ago by rwaldron

  • Status changed from new to closed
  • Resolution set to duplicate

comment:3 Changed 4 years ago by rwaldron

Duplicate of #8052.

comment:4 Changed 4 years ago by jitter

  • Priority changed from undecided to high
  • Component changed from unfiled to manipulation
  • Milestone changed from 1.next to 1.5.1
Version 0, edited 4 years ago by jitter (next)
Note: See TracTickets for help on using tickets.