Fix: remove "null" attributes in svg source #76

This commit is contained in:
cuixiping
2020-01-17 15:34:00 +08:00
parent e69fd11766
commit 2235f81ee7
2 changed files with 15 additions and 3 deletions

View File

@@ -1237,7 +1237,14 @@ export const assignAttributes = function (elem, attrs, suspendLength, unitCheck)
const ns = (key.substr(0, 4) === 'xml:'
? NS.XML
: key.substr(0, 6) === 'xlink:' ? NS.XLINK : null);
if (isNullish(value)) {
if (ns) {
elem.removeAttributeNS(ns, key);
} else {
elem.removeAttribute(key);
}
continue;
}
if (ns) {
elem.setAttributeNS(ns, key, value);
} else if (!unitCheck) {