Bug Tracker

Opened 12 years ago

Closed 12 years ago

#1919 closed bug (invalid)

Can't clone() an XML document in Safari.

Reported by: sunetos Owned by:
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: safari, xml, ajax, clone Cc:
Blocked by: Blocking:

Description

In jQuery 1.2.1, I am unable to use .clone() on an XML document in Safari. Here is the method I am using:

function loadSprites(callbackFunc) {

var worldId = currentWorldId; $.ajax({

url: '/api/' + apiVersion + '/' + apiKey + '/rest/get/style-sheet/worldId=' + worldId + '&ssType=sprite', cache: apiCaching, async: false, type: 'GET', dataType: 'xml', timeout: apiTimeout, error: function(){

alert('Areae Web Services did not respond. Please try again in a few minutes.');

}, success: function(xml){

xmlCachesprite? = $(xml).clone(); xml cloning doesn't work in safari xmlCachesprite? = $(xml);

var browseContainer = $('#media-tab-browse'); var listContainer = $('#media-tab-list');

loadArtAssetBrowser(browseContainer, listContainer, xml, 'sprite', false, selectArtFromDialog, function() {

loadArtAssetBrowser($('#browse-sprites'), undefined, xml, 'sprite', true, undefined, callbackFunc);

});

}

});

}

I left some of the other misc. code in place just to complete the example. Anyway, if I use the .clone() version, it works in Firefox but not Safari (haven't tried other browsers yet).

Change History (2)

comment:1 Changed 12 years ago by brandon

Component: ajaxcore

comment:2 Changed 12 years ago by davidserduke

Resolution: invalid
Status: newclosed

Although this might work in Firefox this isn't intended. Clone is meant for nodes, not for documents. If you want to clone the document you can clone the documentElement like

var clonedRoot = $(xml.documentElement).clone();

which works in all browsers. clone() is working as intended in this case.

Note: See TracTickets for help on using tickets.