Skip to main content

Bug Tracker

Side navigation

#3521 closed bug ()

Opened October 25, 2008 05:35AM UTC

Closed November 11, 2010 11:09PM UTC

Last modified March 14, 2012 11:27PM UTC

remove() fails with IE & ajax

Reported by: arobinson Owned by:
Priority: major Milestone: 1.3
Component: core Version: 1.2.6
Keywords: Cc: arobinson, flesler
Blocked by: Blocking:
Description

When trying to manipulate the xhr responseXML when complete, I get errors in IE7 in jQuery 1.2.6.

The error happens at line 666 (go figure):

data: function( elem, name, data ) {

elem = elem == window ?

windowData :

elem;

var id = elem[ expando ];

// Compute a unique ID for the element

if ( !id )

id = elem[ expando ] = ++uuid;

The code I am using (xml is the xhr.responeXML):

var $scripts = $('script', xml).remove();

If I remove the call to "remove()" the error goes away.

Is there a way around this?

Attachments (0)
Change History (5)

Changed October 26, 2008 02:57PM UTC by flesler comment:1

cc: → arobinson, flesler
need: ReviewTest Case

Can you make a test case to reproduce the problem ?

Changed November 04, 2008 10:37AM UTC by n_2 comment:2

I have this same problem, works fine in ff, fails in ie at line 666. (loading xml from a string, rather than ajax call)

Here is a test case that works in ff, fails in ie. (latest version of jquery, 1.26)

<script type="text/javascript">
    //Xml Parser object
    var xmlParser = {
        xmlDoc : null,
        
        //Loads the xml string into a xml doc
        loadFromDb : function(xmlString) {
            if(window.ActiveXObject) { //ie
                this.xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
                this.xmlDoc.async="false";
                this.xmlDoc.loadXML(xmlString);
            }
            else { //ff/opera
                var parser = new DOMParser();
                this.xmlDoc = parser.parseFromString(xmlString,"text/xml");
            }
        },
        
        toString : function() {
            if (window.ActiveXObject)
                return this.xmlDoc.xml;
            else
                return (new XMLSerializer()).serializeToString(this.xmlDoc);
        },
        
        deleteTest : function() {
            $(this.xmlDoc).find("gd > cd > uid").remove();
        }
    };

    
    //Our test xml string
    var xml = "<gd><cd><uid>0</uid><tm>0</tm><w>0</w><h>0</h></cd></gd>";
    
    //Load our xml up
    xmlParser.loadFromDb(xml);

    //And try and delete the uid node
    xmlParser.deleteTest();
    //Works fine in ff, fails in ie 7, "Object doesn't support this property or method.
    //Line 666 of jquery: id = elem[ expando ] = ++uuid;
    
    alert(xmlParser.toString());
</script>

Changed November 16, 2008 11:17AM UTC by MaRsuPiLaMi comment:3

Another much simplier test-case.

I provided a cross browser implementation so you can test it quite easyly.

<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>JQuery-Testen</title>
<script text="JavaScript" type="text/javascript" src="jquery-1.2.6.js"></script>
<script text="JavaScript" type="text/javascript">
function getDomFromXml(xml) {
        if (typeof ActiveXObject != 'undefined') {
                var dom = new ActiveXObject("Microsoft.XMLDOM");
                dom.async = false;
                dom.loadXML(xml);
        } else {
                parser = new DOMParser();
                dom = parser.parseFromString(xml, "text/xml");
        }
        return dom;
}

function getXmlFromDom(xmlDom) {
    if (typeof ActiveXObject != 'undefined') {
        return xmlDom.xml;
    } else {
        return (new XMLSerializer()).serializeToString(xmlDom);
    };
}

$(document).ready(function(){
    // get 2 doms
    dom = getDomFromXml("<container><repr type=\\"text\\"></repr></container>");
    anotherDom = getDomFromXml("<container><blubb type=\\"text\\">bla</blubb></container>");
     
    repr = $("repr",dom);
    blubb = $("blubb",anotherDom);
    //append the <blubb> element to the <repr> element
    repr.append(blubb);
    alert(getXmlFromDom(dom));
    // should remove the appended <blubb> element
    repr.find("*").remove();
    // ie never reach this line
    alert(getXmlFromDom(dom));
});
</script>
</head><body></body></html>

Changed October 14, 2010 03:14AM UTC by snover comment:4

status: newpending

This ticket has been marked as missing a test case. In an effort to reduce the number of outstanding tickets in the bug tracker, it will be closed automatically in 30 days. In order to prevent this from happening, please provide a working test case. If a test case has already been provided and our records are wrong, please respond to the ticket so that it can be fixed. Thank you!

Changed November 11, 2010 11:09PM UTC by trac-o-bot comment:5

status: pendingclosed

Automatically closed due to 14 days of inactivity.