From c8d5ba7b7e5df166b690c6d08acd3a15c193cadb Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Tue, 16 Feb 2010 18:21:16 +0000 Subject: [PATCH] Fix Issue 485: Make foreignObjects copyable (partial patch by Jacques Distler) git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1392 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 56cda2dd..87acb284 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -1308,7 +1308,12 @@ function BatchCommand(text) { // could use jQuery's inArray(), but I don't know if that's any better var attr = node.attributes.item(i); // TODO: use localName here and grab the namespace URI. Then, make sure that - // anything in our whitelist with a prefix is parsed out properly. + // anything in our whitelist with a prefix is parsed out properly. + // if attr has namespaceURI, ensure that nsMap[namespaceURI]+localName is in + // allowed Attrs + + // TODO: normalize the namespace prefix in declarations + // i.e. "xlink:href" in our whitelist would mean we check that localName matches // "href" and that namespaceURI matches the XLINK namespace var attrName = attr.nodeName; @@ -7509,11 +7514,11 @@ function BatchCommand(text) { // we also do it manually because Opera/Win/non-EN puts , instead of . var copyElem = function(el) { // manually create a copy of the element - var new_el = document.createElementNS(svgns, el.nodeName); + var new_el = document.createElementNS(el.namespaceURI, el.nodeName); $.each(el.attributes, function(i, attr) { - var ns = attr.localName == 'href' ? xlinkns : - attr.prefix == "xml" ? xmlns : null; - new_el.setAttributeNS(ns, attr.nodeName, attr.nodeValue); + if (attr.localName != '-moz-math-font-style') { + new_el.setAttributeNS(attr.namespaceURI, attr.nodeName, attr.nodeValue); + } }); // set the copied element's new id new_el.removeAttribute("id");