Skip to main content

Bug Tracker

Side navigation

#8080 closed bug (duplicate)

Opened January 28, 2011 03:59AM UTC

Closed January 28, 2011 04:31AM UTC

Last modified January 28, 2011 08:52AM UTC

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

Attachments (0)
Change History (4)

Changed January 28, 2011 04:12AM UTC by anonymous comment:1

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/

Changed January 28, 2011 04:31AM UTC by rwaldron comment:2

resolution: → duplicate
status: newclosed

Changed January 28, 2011 04:31AM UTC by rwaldron comment:3

Duplicate of #8052.

Changed January 28, 2011 08:52AM UTC by jitter comment:4

_comment0: → 1296207416089270
component: unfiledmanipulation
milestone: 1.next1.5.1
priority: undecidedhigh

Thanks for taking the time to contribute to the jQuery project by writing a bug report and providing a test case! This is great report with all the debugging already done and some nice test cases.

It's unfortunate that it already was reported before and you didn't happen to find it on the bug tracker.