Add unit test for importing use. Add missing id attribute on use in whitelist

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1270 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Jeff Schiller 2010-01-21 14:12:08 +00:00
parent c8e0a94d50
commit 86ac38547f
2 changed files with 21 additions and 3 deletions

View File

@ -28,7 +28,7 @@ var isOpera = !!window.opera,
// this defines which elements and attributes that we support
// TODO: add <a> elements to this
// TODO: add <marker> to this
// TODO: add <marker> to this and marker attributes
// TODO: add <mask> to this
// TODO: add <pattern> to this
// TODO: add <symbol> to this
@ -52,7 +52,7 @@ var isOpera = !!window.opera,
"svg": ["id", "height", "requiredFeatures", "systemLanguage", "transform", "viewBox", "width", "xmlns", "xmlns:xlink"],
"text": ["fill", "fill-opacity", "fill-rule", "font-family", "font-size", "font-style", "font-weight", "id", "opacity", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "systemLanguage", "transform", "text-anchor", "x", "xml:space", "y"],
"title": [],
"use": ["height", "width", "x", "xlink:href", "y"]
"use": ["height", "id", "width", "x", "xlink:href", "y"]
},
@ -1097,7 +1097,7 @@ function BatchCommand(text) {
// else, remove this element
else {
// remove all children from this node and insert them before this node
// FIXME: in the case of animation elements or tspans this will hardly ever be correct
// FIXME: in the case of animation elements this will hardly ever be correct
var children = [];
while (node.hasChildNodes()) {
children.push(parent.insertBefore(node.firstChild, node));

View File

@ -63,6 +63,24 @@
"Expected identity matrix when multiplying a matrix by its inverse, got " + matrixString(I));
});
module("Import Module");
test("Test import use", function() {
expect(2);
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'/>" +
"<use id='the-use' xlink:href='#the-rect'/>" +
"<use id='foreign-use' xlink:href='somefile.svg#the-rect'/>" +
"</svg>");
var u = document.getElementById("the-use"),
fu = document.getElementById("foreign-use");
equals(true, (u && u.nodeName == "use"), "Did not import <use> element");
equals(null, fu, "Imported a <use> that references a foreign element");
});
});
</script>
</head>