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
master
Jeff Schiller 2010-02-16 18:21:16 +00:00
parent 92b50b4a75
commit c8d5ba7b7e
1 changed files with 10 additions and 5 deletions

View File

@ -1308,7 +1308,12 @@ function BatchCommand(text) {
// could use jQuery's inArray(), but I don't know if that's any better // could use jQuery's inArray(), but I don't know if that's any better
var attr = node.attributes.item(i); var attr = node.attributes.item(i);
// TODO: use localName here and grab the namespace URI. Then, make sure that // 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 // i.e. "xlink:href" in our whitelist would mean we check that localName matches
// "href" and that namespaceURI matches the XLINK namespace // "href" and that namespaceURI matches the XLINK namespace
var attrName = attr.nodeName; var attrName = attr.nodeName;
@ -7509,11 +7514,11 @@ function BatchCommand(text) {
// we also do it manually because Opera/Win/non-EN puts , instead of . // we also do it manually because Opera/Win/non-EN puts , instead of .
var copyElem = function(el) { var copyElem = function(el) {
// manually create a copy of the element // 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) { $.each(el.attributes, function(i, attr) {
var ns = attr.localName == 'href' ? xlinkns : if (attr.localName != '-moz-math-font-style') {
attr.prefix == "xml" ? xmlns : null; new_el.setAttributeNS(attr.namespaceURI, attr.nodeName, attr.nodeValue);
new_el.setAttributeNS(ns, attr.nodeName, attr.nodeValue); }
}); });
// set the copied element's new id // set the copied element's new id
new_el.removeAttribute("id"); new_el.removeAttribute("id");