Fix Issue 486: Remove uses without href to prevent Safari crash. Turns all unit tests green
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1408 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
60c2d8c007
commit
8e0bf800bf
|
@ -45,17 +45,6 @@ script type="text/javascript" src="locale/locale.min.js"></script-->
|
||||||
<title>SVG-edit</title>
|
<title>SVG-edit</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script type="text/javascript"
|
|
||||||
src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"> </script>
|
|
||||||
|
|
||||||
<div id="placeholder"></div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
CFInstall.check({
|
|
||||||
node: "placeholder",
|
|
||||||
destination: "http://www.waikiki.com"
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<div id="svg_editor">
|
<div id="svg_editor">
|
||||||
|
|
||||||
<div id="workarea">
|
<div id="workarea">
|
||||||
|
|
|
@ -1385,6 +1385,11 @@ function BatchCommand(text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Safari crashes on a <use> 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,
|
// if the element has attributes pointing to a non-local reference,
|
||||||
// need to remove the attribute
|
// need to remove the attribute
|
||||||
$.each(["clip-path", "fill", "marker-end", "marker-mid", "marker-start", "mask", "stroke"],function(i,attr) {
|
$.each(["clip-path", "fill", "marker-end", "marker-mid", "marker-start", "mask", "stroke"],function(i,attr) {
|
||||||
|
|
|
@ -124,19 +124,22 @@
|
||||||
module("Import Module");
|
module("Import Module");
|
||||||
|
|
||||||
test("Test import use", function() {
|
test("Test import use", function() {
|
||||||
expect(2);
|
expect(3);
|
||||||
|
|
||||||
svgCanvas.setSvgString("<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='400' x='300'>" +
|
svgCanvas.setSvgString("<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='400' x='300'>" +
|
||||||
"<rect id='the-rect' width='200' height='200'/>" +
|
"<rect id='the-rect' width='200' height='200'/>" +
|
||||||
"<use id='the-use' xlink:href='#the-rect'/>" +
|
"<use id='the-use' xlink:href='#the-rect'/>" +
|
||||||
"<use id='foreign-use' xlink:href='somefile.svg#the-rect'/>" +
|
"<use id='foreign-use' xlink:href='somefile.svg#the-rect'/>" +
|
||||||
|
"<use id='no-use'/>" +
|
||||||
"</svg>");
|
"</svg>");
|
||||||
|
|
||||||
var u = document.getElementById("the-use"),
|
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 <use> element");
|
equals((u && u.nodeName == "use"), true, "Did not import <use> element");
|
||||||
equals((fu && !fu.getAttributeNS(xlinkns,"href")), true, "Did not remove reference to foreign element in <use>");
|
equals(fu, null, "Removed <use> element that had a foreign href");
|
||||||
|
equals(nfu, null, "Removed <use> element that had no href");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Test getUrlFromAttr", function() {
|
test("Test getUrlFromAttr", function() {
|
||||||
|
|
Loading…
Reference in New Issue