svg import issues
parent
11e72bf2df
commit
23f5bfd4a7
|
@ -147,6 +147,7 @@ svgedit.sanitize.sanitizeSvg = function(node) {
|
||||||
if(!node.nodeValue.length) node.parentNode.removeChild(node);
|
if(!node.nodeValue.length) node.parentNode.removeChild(node);
|
||||||
}
|
}
|
||||||
if (node.nodeType != 1) return;
|
if (node.nodeType != 1) return;
|
||||||
|
|
||||||
var doc = node.ownerDocument;
|
var doc = node.ownerDocument;
|
||||||
var parent = node.parentNode;
|
var parent = node.parentNode;
|
||||||
// can parent ever be null here? I think the root node's parent is the document...
|
// can parent ever be null here? I think the root node's parent is the document...
|
||||||
|
@ -195,7 +196,7 @@ svgedit.sanitize.sanitizeSvg = function(node) {
|
||||||
|
|
||||||
// for the style attribute, rewrite it in terms of XML presentational attributes
|
// for the style attribute, rewrite it in terms of XML presentational attributes
|
||||||
if (attrName == "style") {
|
if (attrName == "style") {
|
||||||
var props = attr.nodeValue.split(";"),
|
var props = attr.nodeValue.replace(' ', '').split(";"),
|
||||||
p = props.length;
|
p = props.length;
|
||||||
while(p--) {
|
while(p--) {
|
||||||
var nv = props[p].split(":");
|
var nv = props[p].split(":");
|
||||||
|
@ -220,7 +221,7 @@ svgedit.sanitize.sanitizeSvg = function(node) {
|
||||||
"radialGradient", "textPath", "use"].indexOf(node.nodeName) >= 0)
|
"radialGradient", "textPath", "use"].indexOf(node.nodeName) >= 0)
|
||||||
{
|
{
|
||||||
// TODO: we simply check if the first character is a #, is this bullet-proof?
|
// TODO: we simply check if the first character is a #, is this bullet-proof?
|
||||||
if (href[0] != "#") {
|
if (href[0] !== "#") {
|
||||||
// remove the attribute (but keep the element)
|
// remove the attribute (but keep the element)
|
||||||
svgedit.utilities.setHref(node, "");
|
svgedit.utilities.setHref(node, "");
|
||||||
node.removeAttributeNS(xlinkns, "href");
|
node.removeAttributeNS(xlinkns, "href");
|
||||||
|
|
|
@ -5786,6 +5786,8 @@ this.setSvgString = function(xmlString) {
|
||||||
try {
|
try {
|
||||||
// convert string into XML document
|
// convert string into XML document
|
||||||
var newDoc = svgedit.utilities.text2xml(xmlString);
|
var newDoc = svgedit.utilities.text2xml(xmlString);
|
||||||
|
//var parser = new DOMParser();
|
||||||
|
//var newDoc = parser.parseFromString(stringContainingXMLSource, "image/svg+xml");
|
||||||
|
|
||||||
this.prepareSvg(newDoc);
|
this.prepareSvg(newDoc);
|
||||||
|
|
||||||
|
|
|
@ -218,6 +218,10 @@ svgedit.utilities.text2xml = function(sXML) {
|
||||||
sXML = sXML.replace(/<(\/?)svg:/g, '<$1').replace('xmlns:svg', 'xmlns');
|
sXML = sXML.replace(/<(\/?)svg:/g, '<$1').replace('xmlns:svg', 'xmlns');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(sXML.indexOf('xlink:href') >= 0) {
|
||||||
|
sXML = sXML.replace('xlink:href', 'href');
|
||||||
|
}
|
||||||
|
|
||||||
var out;
|
var out;
|
||||||
try{
|
try{
|
||||||
var dXML = (window.DOMParser)?new DOMParser():new ActiveXObject("Microsoft.XMLDOM");
|
var dXML = (window.DOMParser)?new DOMParser():new ActiveXObject("Microsoft.XMLDOM");
|
||||||
|
|
Loading…
Reference in New Issue