Correctly handle trailing slashes in XML attribute namespaces.

See #984
This commit is contained in:
Jürg Lehni 2016-03-14 18:31:45 +01:00
parent 7dd110f5b2
commit af1c481523

View file

@ -24,9 +24,10 @@ var SvgElement = new function() {
attributeNamespace = { attributeNamespace = {
href: xlink, href: xlink,
xlink: xmlns, xlink: xmlns,
xmlns: xmlns, // Only the xmlns attribute needs the trailing slash. See #984
xmlns: xmlns + '/',
// IE needs the xmlns namespace when setting 'xmlns:xlink'. See #984 // IE needs the xmlns namespace when setting 'xmlns:xlink'. See #984
'xmlns:xlink': xmlns 'xmlns:xlink': xmlns + '/'
}; };
function create(tag, attributes, formatter) { function create(tag, attributes, formatter) {
@ -48,8 +49,7 @@ var SvgElement = new function() {
if (typeof value === 'number' && formatter) if (typeof value === 'number' && formatter)
value = formatter.number(value); value = formatter.number(value);
if (namespace) { if (namespace) {
// IE needs trailing slashes, but only when setting. See #984 node.setAttributeNS(namespace, name, value);
node.setAttributeNS(namespace + '/', name, value);
} else { } else {
node.setAttribute(name, value); node.setAttribute(name, value);
} }