diff --git a/editor/svg-editor.html b/editor/svg-editor.html index 099fd905..c3d8fb05 100644 --- a/editor/svg-editor.html +++ b/editor/svg-editor.html @@ -45,17 +45,6 @@ script type="text/javascript" src="locale/locale.min.js"> SVG-edit - - -
- -
diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 12209a90..f6f3dab7 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -1385,6 +1385,11 @@ function BatchCommand(text) { } } + // Safari crashes on a without a xlink:href, so we just remove the node here + if (node.nodeName == "use" && !node.getAttributeNS(xlinkns,"href")) { + parent.removeChild(node); + return; + } // if the element has attributes pointing to a non-local reference, // need to remove the attribute $.each(["clip-path", "fill", "marker-end", "marker-mid", "marker-start", "mask", "stroke"],function(i,attr) { diff --git a/test/test1.html b/test/test1.html index c28be868..b29589d2 100644 --- a/test/test1.html +++ b/test/test1.html @@ -124,19 +124,22 @@ module("Import Module"); test("Test import use", function() { - expect(2); + expect(3); svgCanvas.setSvgString("" + "" + "" + "" + + "" + ""); var u = document.getElementById("the-use"), - fu = document.getElementById("foreign-use"); + fu = document.getElementById("foreign-use"), + nfu = document.getElementById("no-use"); equals((u && u.nodeName == "use"), true, "Did not import element"); - equals((fu && !fu.getAttributeNS(xlinkns,"href")), true, "Did not remove reference to foreign element in "); + equals(fu, null, "Removed element that had a foreign href"); + equals(nfu, null, "Removed element that had no href"); }); test("Test getUrlFromAttr", function() {