Fix: remove "null" attributes in svg source #76
parent
e69fd11766
commit
2235f81ee7
|
@ -3744,6 +3744,10 @@ this.svgToString = function (elem, indent) {
|
||||||
let attrVal = toXml(attr.value);
|
let attrVal = toXml(attr.value);
|
||||||
// remove bogus attributes added by Gecko
|
// remove bogus attributes added by Gecko
|
||||||
if (mozAttrs.includes(attr.localName)) { continue; }
|
if (mozAttrs.includes(attr.localName)) { continue; }
|
||||||
|
if (attrVal === 'null') {
|
||||||
|
const styleName = attr.localName.replace(/-[a-z]/g, (s) => s[1].toUpperCase());
|
||||||
|
if (Object.prototype.hasOwnProperty.call(elem.style, styleName)) { continue; }
|
||||||
|
}
|
||||||
if (attrVal !== '') {
|
if (attrVal !== '') {
|
||||||
if (attrVal.startsWith('pointer-events')) { continue; }
|
if (attrVal.startsWith('pointer-events')) { continue; }
|
||||||
if (attr.localName === 'class' && attrVal.startsWith('se_')) { continue; }
|
if (attr.localName === 'class' && attrVal.startsWith('se_')) { continue; }
|
||||||
|
@ -3786,7 +3790,7 @@ this.svgToString = function (elem, indent) {
|
||||||
switch (child.nodeType) {
|
switch (child.nodeType) {
|
||||||
case 1: // element node
|
case 1: // element node
|
||||||
out.push('\n');
|
out.push('\n');
|
||||||
out.push(this.svgToString(childs.item(i), indent));
|
out.push(this.svgToString(child, indent));
|
||||||
break;
|
break;
|
||||||
case 3: { // text node
|
case 3: { // text node
|
||||||
const str = child.nodeValue.replace(/^\s+|\s+$/g, '');
|
const str = child.nodeValue.replace(/^\s+|\s+$/g, '');
|
||||||
|
@ -4072,7 +4076,8 @@ this.exportPDF = async function (
|
||||||
// We do not currently have these paths configurable as they are
|
// We do not currently have these paths configurable as they are
|
||||||
// currently global-only, so not Rolled-up
|
// currently global-only, so not Rolled-up
|
||||||
'jspdf/underscore-min.js',
|
'jspdf/underscore-min.js',
|
||||||
'jspdf/jspdf.min.js'
|
// 'jspdf/jspdf.min.js',
|
||||||
|
'../../svgedit-myfix/editor/jspdf/jspdf-1.0.150.debug.js'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const modularVersion = !('svgEditor' in window) ||
|
const modularVersion = !('svgEditor' in window) ||
|
||||||
|
|
|
@ -1237,7 +1237,14 @@ export const assignAttributes = function (elem, attrs, suspendLength, unitCheck)
|
||||||
const ns = (key.substr(0, 4) === 'xml:'
|
const ns = (key.substr(0, 4) === 'xml:'
|
||||||
? NS.XML
|
? NS.XML
|
||||||
: key.substr(0, 6) === 'xlink:' ? NS.XLINK : null);
|
: key.substr(0, 6) === 'xlink:' ? NS.XLINK : null);
|
||||||
|
if (isNullish(value)) {
|
||||||
|
if (ns) {
|
||||||
|
elem.removeAttributeNS(ns, key);
|
||||||
|
} else {
|
||||||
|
elem.removeAttribute(key);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (ns) {
|
if (ns) {
|
||||||
elem.setAttributeNS(ns, key, value);
|
elem.setAttributeNS(ns, key, value);
|
||||||
} else if (!unitCheck) {
|
} else if (!unitCheck) {
|
||||||
|
|
Loading…
Reference in New Issue