Skip to main content

Bug Tracker

Side navigation

#1919 closed bug (invalid)

Opened November 13, 2007 05:47PM UTC

Closed December 12, 2007 12:52AM UTC

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){

xmlCache['sprite'] = $(xml).clone(); xml cloning doesn't work in safari

xmlCache['sprite'] = $(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).

Attachments (0)
Change History (2)

Changed November 14, 2007 03:41AM UTC by brandon comment:1

component: ajaxcore

Changed December 12, 2007 12:52AM UTC by davidserduke comment:2

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.