Hopefully fix 889: adopt/import nodes and handle CDATA nodes (patch by asyazwan)
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2059 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
0f85c54128
commit
2b669ce556
|
@ -5254,6 +5254,13 @@ this.svgToString = function(elem, indent) {
|
||||||
out.push(toXml(str) + "");
|
out.push(toXml(str) + "");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 4: // cdata node
|
||||||
|
out.push("\n");
|
||||||
|
out.push(new Array(indent+1).join(" "));
|
||||||
|
out.push("<![CDATA[");
|
||||||
|
out.push(child.nodeValue);
|
||||||
|
out.push("]]>");
|
||||||
|
break;
|
||||||
case 8: // comment
|
case 8: // comment
|
||||||
out.push("\n");
|
out.push("\n");
|
||||||
out.push(new Array(indent+1).join(" "));
|
out.push(new Array(indent+1).join(" "));
|
||||||
|
@ -5734,14 +5741,15 @@ this.setSvgString = function(xmlString) {
|
||||||
batchCmd.addSubCommand(new RemoveElementCommand(oldzoom, nextSibling, svgroot));
|
batchCmd.addSubCommand(new RemoveElementCommand(oldzoom, nextSibling, svgroot));
|
||||||
|
|
||||||
// set new svg document
|
// set new svg document
|
||||||
var _tmpDoc = newDoc.documentElement;
|
// If DOM3 adoptNode() available, use it. Otherwise fall back to DOM2 importNode()
|
||||||
//TODO: remove isChrome() blocks when importNode is fixed
|
if(svgdoc.adoptNode) {
|
||||||
//Issue: https://code.google.com/p/chromium/issues/detail?id=57871
|
svgcontent = svgdoc.adoptNode(newDoc.documentElement);
|
||||||
if(svgedit.browser.isChrome()) {
|
}
|
||||||
_tmpDoc = $(newDoc.documentElement).clone(true)[0];
|
else {
|
||||||
|
svgcontent = svgdoc.importNode(newDoc.documentElement, true);
|
||||||
}
|
}
|
||||||
svgcontent = svgroot.appendChild(_tmpDoc);
|
|
||||||
|
|
||||||
|
svgroot.appendChild(svgcontent);
|
||||||
var content = $(svgcontent);
|
var content = $(svgcontent);
|
||||||
|
|
||||||
canvas.current_drawing_ = new svgedit.draw.Drawing(svgcontent, idprefix);
|
canvas.current_drawing_ = new svgedit.draw.Drawing(svgcontent, idprefix);
|
||||||
|
@ -5928,7 +5936,14 @@ this.importSvgString = function(xmlString) {
|
||||||
this.prepareSvg(newDoc);
|
this.prepareSvg(newDoc);
|
||||||
|
|
||||||
// import new svg document into our document
|
// import new svg document into our document
|
||||||
var svg = svgdoc.importNode(newDoc.documentElement, true);
|
var svg;
|
||||||
|
// If DOM3 adoptNode() available, use it. Otherwise fall back to DOM2 importNode()
|
||||||
|
if(svgdoc.adoptNode) {
|
||||||
|
svg = svgdoc.adoptNode(newDoc.documentElement);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
svg = svgdoc.importNode(newDoc.documentElement, true);
|
||||||
|
}
|
||||||
|
|
||||||
uniquifyElems(svg);
|
uniquifyElems(svg);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue