- Refactoring: Avoid redundant use of *AttributeNS methods with

`null` value; just use *Attribute methods without namespace
master
Brett Zamir 2018-10-23 18:13:36 +08:00
parent f4bbd34d34
commit 2835ec11b6
20 changed files with 98 additions and 96 deletions

View File

@ -5,6 +5,8 @@
- Fix (jgraduate->jpicker): Actually fix issue with color val check when no - Fix (jgraduate->jpicker): Actually fix issue with color val check when no
other proper results (equal to "all"); prior fix had not covered other proper results (equal to "all"); prior fix had not covered
original intention original intention
- Refactoring: Avoid redundant use of \*AttributeNS methods with
`null` value; just use \*Attribute methods without namespace
# 3.0.0 # 3.0.0

4
dist/canvg.js vendored
View File

@ -4393,8 +4393,8 @@ var canvg = (function (exports) {
_createClass(_class46, [{ _createClass(_class46, [{
key: "apply", key: "apply",
value: function apply(ctx, x, y, width, height) { value: function apply(ctx, x, y, width, height) {
if (typeof canvasRGBA_ === 'undefined') { if (typeof canvasRGBA_ !== 'function') {
svg.log('ERROR: `setStackBlurCanvasRGBA` must be run for blur to work'); svg.log('ERROR: The function `setStackBlurCanvasRGBA` must be present for blur to work');
return; return;
} // Todo: This might not be a problem anymore with out `instanceof` fix } // Todo: This might not be a problem anymore with out `instanceof` fix
// StackBlur requires canvas be on document // StackBlur requires canvas be on document

View File

@ -235,7 +235,7 @@ var svgEditorExtension_polygon = (function () {
strokeWidth = c.strokeWidth, strokeWidth = c.strokeWidth,
sides = c.sides, sides = c.sides,
edg = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / 1.5; edg = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / 1.5;
newFO.setAttributeNS(null, 'edge', edg); newFO.setAttribute('edge', edg);
var inradius = edg / 2 * cot(Math.PI / sides); var inradius = edg / 2 * cot(Math.PI / sides);
var circumradius = inradius * sec(Math.PI / sides); var circumradius = inradius * sec(Math.PI / sides);
var points = ''; var points = '';
@ -248,11 +248,11 @@ var svgEditorExtension_polygon = (function () {
} // const poly = newFO.createElementNS(NS.SVG, 'polygon'); } // const poly = newFO.createElementNS(NS.SVG, 'polygon');
newFO.setAttributeNS(null, 'points', points); newFO.setAttribute('points', points);
newFO.setAttributeNS(null, 'fill', fill); newFO.setAttribute('fill', fill);
newFO.setAttributeNS(null, 'stroke', strokecolor); newFO.setAttribute('stroke', strokecolor);
newFO.setAttributeNS(null, 'stroke-width', strokeWidth); // newFO.setAttributeNS(null, 'transform', 'rotate(-90)'); newFO.setAttribute('stroke-width', strokeWidth); // newFO.setAttribute('transform', 'rotate(-90)');
// const shape = newFO.getAttributeNS(null, 'shape'); // const shape = newFO.getAttribute('shape');
// newFO.append(poly); // newFO.append(poly);
// DrawPoly(cx, cy, sides, edg, orient); // DrawPoly(cx, cy, sides, edg, orient);
@ -280,7 +280,7 @@ var svgEditorExtension_polygon = (function () {
while (i--) { while (i--) {
var elem = selElems[i]; var elem = selElems[i];
if (elem && elem.getAttributeNS(null, 'shape') === 'regularPoly') { if (elem && elem.getAttribute('shape') === 'regularPoly') {
if (opts.selectedElement && !opts.multiselected) { if (opts.selectedElement && !opts.multiselected) {
$('#polySides').val(elem.getAttribute('sides')); $('#polySides').val(elem.getAttribute('sides'));
showPanel(true); showPanel(true);

View File

@ -4370,8 +4370,8 @@ var svgEditorExtension_server_moinsave = (function () {
_createClass(_class46, [{ _createClass(_class46, [{
key: "apply", key: "apply",
value: function apply(ctx, x, y, width, height) { value: function apply(ctx, x, y, width, height) {
if (typeof canvasRGBA_ === 'undefined') { if (typeof canvasRGBA_ !== 'function') {
svg.log('ERROR: `setStackBlurCanvasRGBA` must be run for blur to work'); svg.log('ERROR: The function `setStackBlurCanvasRGBA` must be present for blur to work');
return; return;
} // Todo: This might not be a problem anymore with out `instanceof` fix } // Todo: This might not be a problem anymore with out `instanceof` fix
// StackBlur requires canvas be on document // StackBlur requires canvas be on document

View File

@ -4370,8 +4370,8 @@ var svgEditorExtension_server_opensave = (function () {
_createClass(_class46, [{ _createClass(_class46, [{
key: "apply", key: "apply",
value: function apply(ctx, x, y, width, height) { value: function apply(ctx, x, y, width, height) {
if (typeof canvasRGBA_ === 'undefined') { if (typeof canvasRGBA_ !== 'function') {
svg.log('ERROR: `setStackBlurCanvasRGBA` must be run for blur to work'); svg.log('ERROR: The function `setStackBlurCanvasRGBA` must be present for blur to work');
return; return;
} // Todo: This might not be a problem anymore with out `instanceof` fix } // Todo: This might not be a problem anymore with out `instanceof` fix
// StackBlur requires canvas be on document // StackBlur requires canvas be on document

View File

@ -195,8 +195,8 @@ var svgEditorExtension_star = (function () {
orient = c.orient, orient = c.orient,
circumradius = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / 1.5, circumradius = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / 1.5,
inradius = circumradius / document.getElementById('starRadiusMulitplier').value; inradius = circumradius / document.getElementById('starRadiusMulitplier').value;
newFO.setAttributeNS(null, 'r', circumradius); newFO.setAttribute('r', circumradius);
newFO.setAttributeNS(null, 'r2', inradius); newFO.setAttribute('r2', inradius);
var polyPoints = ''; var polyPoints = '';
for (var s = 0; point >= s; s++) { for (var s = 0; point >= s; s++) {
@ -228,13 +228,13 @@ var svgEditorExtension_star = (function () {
} }
} }
newFO.setAttributeNS(null, 'points', polyPoints); newFO.setAttribute('points', polyPoints);
newFO.setAttributeNS(null, 'fill', fill); newFO.setAttribute('fill', fill);
newFO.setAttributeNS(null, 'stroke', strokecolor); newFO.setAttribute('stroke', strokecolor);
newFO.setAttributeNS(null, 'stroke-width', strokeWidth); newFO.setAttribute('stroke-width', strokeWidth);
/* const shape = */ /* const shape = */
newFO.getAttributeNS(null, 'shape'); newFO.getAttribute('shape');
return { return {
started: true started: true
}; };
@ -258,7 +258,7 @@ var svgEditorExtension_star = (function () {
while (i--) { while (i--) {
var elem = selElems[i]; var elem = selElems[i];
if (elem && elem.getAttributeNS(null, 'shape') === 'star') { if (elem && elem.getAttribute('shape') === 'star') {
if (opts.selectedElement && !opts.multiselected) { if (opts.selectedElement && !opts.multiselected) {
// $('#starRadiusMulitplier').val(elem.getAttribute('r2')); // $('#starRadiusMulitplier').val(elem.getAttribute('r2'));
$('#starNumPoints').val(elem.getAttribute('point')); $('#starNumPoints').val(elem.getAttribute('point'));

20
dist/index-es.js vendored
View File

@ -15152,12 +15152,12 @@ function SvgCanvas(container, config) {
if (iswebkit) { if (iswebkit) {
delayedStroke = function delayedStroke(ele) { delayedStroke = function delayedStroke(ele) {
var _stroke = ele.getAttributeNS(null, 'stroke'); var _stroke = ele.getAttribute('stroke');
ele.removeAttributeNS(null, 'stroke'); // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker ele.removeAttribute('stroke'); // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker
if (_stroke !== null) setTimeout(function () { if (_stroke !== null) setTimeout(function () {
ele.setAttributeNS(null, 'stroke', _stroke); ele.setAttribute('stroke', _stroke);
}, 0); }, 0);
}; };
} }
@ -15683,8 +15683,8 @@ function SvgCanvas(container, config) {
y2 = xya.y; y2 = xya.y;
} }
shape.setAttributeNS(null, 'x2', x2); shape.setAttribute('x2', x2);
shape.setAttributeNS(null, 'y2', y2); shape.setAttribute('y2', y2);
break; break;
} }
@ -15738,7 +15738,7 @@ function SvgCanvas(container, config) {
rad = snapToGrid(rad); rad = snapToGrid(rad);
} }
shape.setAttributeNS(null, 'r', rad); shape.setAttribute('r', rad);
break; break;
} }
@ -15756,9 +15756,9 @@ function SvgCanvas(container, config) {
cy = snapToGrid(cy); cy = snapToGrid(cy);
} }
shape.setAttributeNS(null, 'rx', Math.abs(x - cx)); shape.setAttribute('rx', Math.abs(x - cx));
var ry = Math.abs(evt.shiftKey ? x - cx : y - cy); var ry = Math.abs(evt.shiftKey ? x - cx : y - cy);
shape.setAttributeNS(null, 'ry', ry); shape.setAttribute('ry', ry);
break; break;
} }
@ -15775,7 +15775,7 @@ function SvgCanvas(container, config) {
case 'fhpath': case 'fhpath':
{ {
// dAttr += + realX + ',' + realY + ' '; // dAttr += + realX + ',' + realY + ' ';
// shape.setAttributeNS(null, 'points', dAttr); // shape.setAttribute('points', dAttr);
end.x = realX; end.x = realX;
end.y = realY; end.y = realY;
@ -22001,7 +22001,7 @@ function jqPluginSVGIcons ($) {
var svgroot = document.createElementNS(svgns, 'svg'); // Per https://www.w3.org/TR/xml-names11/#defaulting, the namespace for var svgroot = document.createElementNS(svgns, 'svg'); // Per https://www.w3.org/TR/xml-names11/#defaulting, the namespace for
// attributes should have no value. // attributes should have no value.
svgroot.setAttributeNS(null, 'viewBox', [0, 0, iconW, iconH].join(' ')); svgroot.setAttribute('viewBox', [0, 0, iconW, iconH].join(' '));
var svg = elem.getElementsByTagNameNS(svgns, 'svg')[0]; // Make flexible by converting width/height to viewBox var svg = elem.getElementsByTagNameNS(svgns, 'svg')[0]; // Make flexible by converting width/height to viewBox
var w = svg.getAttribute('width'); var w = svg.getAttribute('width');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

20
dist/index-umd.js vendored
View File

@ -15158,12 +15158,12 @@
if (iswebkit) { if (iswebkit) {
delayedStroke = function delayedStroke(ele) { delayedStroke = function delayedStroke(ele) {
var _stroke = ele.getAttributeNS(null, 'stroke'); var _stroke = ele.getAttribute('stroke');
ele.removeAttributeNS(null, 'stroke'); // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker ele.removeAttribute('stroke'); // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker
if (_stroke !== null) setTimeout(function () { if (_stroke !== null) setTimeout(function () {
ele.setAttributeNS(null, 'stroke', _stroke); ele.setAttribute('stroke', _stroke);
}, 0); }, 0);
}; };
} }
@ -15689,8 +15689,8 @@
y2 = xya.y; y2 = xya.y;
} }
shape.setAttributeNS(null, 'x2', x2); shape.setAttribute('x2', x2);
shape.setAttributeNS(null, 'y2', y2); shape.setAttribute('y2', y2);
break; break;
} }
@ -15744,7 +15744,7 @@
rad = snapToGrid(rad); rad = snapToGrid(rad);
} }
shape.setAttributeNS(null, 'r', rad); shape.setAttribute('r', rad);
break; break;
} }
@ -15762,9 +15762,9 @@
cy = snapToGrid(cy); cy = snapToGrid(cy);
} }
shape.setAttributeNS(null, 'rx', Math.abs(x - cx)); shape.setAttribute('rx', Math.abs(x - cx));
var ry = Math.abs(evt.shiftKey ? x - cx : y - cy); var ry = Math.abs(evt.shiftKey ? x - cx : y - cy);
shape.setAttributeNS(null, 'ry', ry); shape.setAttribute('ry', ry);
break; break;
} }
@ -15781,7 +15781,7 @@
case 'fhpath': case 'fhpath':
{ {
// dAttr += + realX + ',' + realY + ' '; // dAttr += + realX + ',' + realY + ' ';
// shape.setAttributeNS(null, 'points', dAttr); // shape.setAttribute('points', dAttr);
end.x = realX; end.x = realX;
end.y = realY; end.y = realY;
@ -22007,7 +22007,7 @@
var svgroot = document.createElementNS(svgns, 'svg'); // Per https://www.w3.org/TR/xml-names11/#defaulting, the namespace for var svgroot = document.createElementNS(svgns, 'svg'); // Per https://www.w3.org/TR/xml-names11/#defaulting, the namespace for
// attributes should have no value. // attributes should have no value.
svgroot.setAttributeNS(null, 'viewBox', [0, 0, iconW, iconH].join(' ')); svgroot.setAttribute('viewBox', [0, 0, iconW, iconH].join(' '));
var svg = elem.getElementsByTagNameNS(svgns, 'svg')[0]; // Make flexible by converting width/height to viewBox var svg = elem.getElementsByTagNameNS(svgns, 'svg')[0]; // Make flexible by converting width/height to viewBox
var w = svg.getAttribute('width'); var w = svg.getAttribute('width');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -220,7 +220,7 @@ export default {
let y = opts.mouse_y; let y = opts.mouse_y;
const {cx, cy, fill, strokecolor, strokeWidth, sides} = c, // {orient} = c, const {cx, cy, fill, strokecolor, strokeWidth, sides} = c, // {orient} = c,
edg = (Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy))) / 1.5; edg = (Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy))) / 1.5;
newFO.setAttributeNS(null, 'edge', edg); newFO.setAttribute('edge', edg);
const inradius = (edg / 2) * cot(Math.PI / sides); const inradius = (edg / 2) * cot(Math.PI / sides);
const circumradius = inradius * sec(Math.PI / sides); const circumradius = inradius * sec(Math.PI / sides);
@ -234,12 +234,12 @@ export default {
} }
// const poly = newFO.createElementNS(NS.SVG, 'polygon'); // const poly = newFO.createElementNS(NS.SVG, 'polygon');
newFO.setAttributeNS(null, 'points', points); newFO.setAttribute('points', points);
newFO.setAttributeNS(null, 'fill', fill); newFO.setAttribute('fill', fill);
newFO.setAttributeNS(null, 'stroke', strokecolor); newFO.setAttribute('stroke', strokecolor);
newFO.setAttributeNS(null, 'stroke-width', strokeWidth); newFO.setAttribute('stroke-width', strokeWidth);
// newFO.setAttributeNS(null, 'transform', 'rotate(-90)'); // newFO.setAttribute('transform', 'rotate(-90)');
// const shape = newFO.getAttributeNS(null, 'shape'); // const shape = newFO.getAttribute('shape');
// newFO.append(poly); // newFO.append(poly);
// DrawPoly(cx, cy, sides, edg, orient); // DrawPoly(cx, cy, sides, edg, orient);
return { return {
@ -266,7 +266,7 @@ export default {
let i = selElems.length; let i = selElems.length;
while (i--) { while (i--) {
const elem = selElems[i]; const elem = selElems[i];
if (elem && elem.getAttributeNS(null, 'shape') === 'regularPoly') { if (elem && elem.getAttribute('shape') === 'regularPoly') {
if (opts.selectedElement && !opts.multiselected) { if (opts.selectedElement && !opts.multiselected) {
$('#polySides').val(elem.getAttribute('sides')); $('#polySides').val(elem.getAttribute('sides'));

View File

@ -153,8 +153,8 @@ export default {
const {cx, cy, fill, strokecolor, strokeWidth, radialshift, point, orient} = c, const {cx, cy, fill, strokecolor, strokeWidth, radialshift, point, orient} = c,
circumradius = (Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy))) / 1.5, circumradius = (Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy))) / 1.5,
inradius = circumradius / document.getElementById('starRadiusMulitplier').value; inradius = circumradius / document.getElementById('starRadiusMulitplier').value;
newFO.setAttributeNS(null, 'r', circumradius); newFO.setAttribute('r', circumradius);
newFO.setAttributeNS(null, 'r2', inradius); newFO.setAttribute('r2', inradius);
let polyPoints = ''; let polyPoints = '';
for (let s = 0; point >= s; s++) { for (let s = 0; point >= s; s++) {
@ -185,11 +185,11 @@ export default {
polyPoints += x + ',' + y + ' '; polyPoints += x + ',' + y + ' ';
} }
} }
newFO.setAttributeNS(null, 'points', polyPoints); newFO.setAttribute('points', polyPoints);
newFO.setAttributeNS(null, 'fill', fill); newFO.setAttribute('fill', fill);
newFO.setAttributeNS(null, 'stroke', strokecolor); newFO.setAttribute('stroke', strokecolor);
newFO.setAttributeNS(null, 'stroke-width', strokeWidth); newFO.setAttribute('stroke-width', strokeWidth);
/* const shape = */ newFO.getAttributeNS(null, 'shape'); /* const shape = */ newFO.getAttribute('shape');
return { return {
started: true started: true
@ -213,7 +213,7 @@ export default {
let i = selElems.length; let i = selElems.length;
while (i--) { while (i--) {
const elem = selElems[i]; const elem = selElems[i];
if (elem && elem.getAttributeNS(null, 'shape') === 'star') { if (elem && elem.getAttribute('shape') === 'star') {
if (opts.selectedElement && !opts.multiselected) { if (opts.selectedElement && !opts.multiselected) {
// $('#starRadiusMulitplier').val(elem.getAttribute('r2')); // $('#starRadiusMulitplier').val(elem.getAttribute('r2'));
$('#starNumPoints').val(elem.getAttribute('point')); $('#starNumPoints').val(elem.getAttribute('point'));

View File

@ -1850,10 +1850,10 @@ const mouseDown = function (evt) {
let delayedStroke; let delayedStroke;
if (iswebkit) { if (iswebkit) {
delayedStroke = function (ele) { delayedStroke = function (ele) {
const _stroke = ele.getAttributeNS(null, 'stroke'); const _stroke = ele.getAttribute('stroke');
ele.removeAttributeNS(null, 'stroke'); ele.removeAttribute('stroke');
// Re-apply stroke after delay. Anything higher than 1 seems to cause flicker // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker
if (_stroke !== null) setTimeout(function () { ele.setAttributeNS(null, 'stroke', _stroke); }, 0); if (_stroke !== null) setTimeout(function () { ele.setAttribute('stroke', _stroke); }, 0);
}; };
} }
mouseTarget.style.vectorEffect = 'non-scaling-stroke'; mouseTarget.style.vectorEffect = 'non-scaling-stroke';
@ -2308,8 +2308,8 @@ const mouseMove = function (evt) {
y2 = xya.y; y2 = xya.y;
} }
shape.setAttributeNS(null, 'x2', x2); shape.setAttribute('x2', x2);
shape.setAttributeNS(null, 'y2', y2); shape.setAttribute('y2', y2);
break; break;
} case 'foreignObject': } case 'foreignObject':
// fall through // fall through
@ -2354,7 +2354,7 @@ const mouseMove = function (evt) {
if (curConfig.gridSnapping) { if (curConfig.gridSnapping) {
rad = snapToGrid(rad); rad = snapToGrid(rad);
} }
shape.setAttributeNS(null, 'r', rad); shape.setAttribute('r', rad);
break; break;
} case 'ellipse': { } case 'ellipse': {
c = $(shape).attr(['cx', 'cy']); c = $(shape).attr(['cx', 'cy']);
@ -2365,9 +2365,9 @@ const mouseMove = function (evt) {
y = snapToGrid(y); y = snapToGrid(y);
cy = snapToGrid(cy); cy = snapToGrid(cy);
} }
shape.setAttributeNS(null, 'rx', Math.abs(x - cx)); shape.setAttribute('rx', Math.abs(x - cx));
const ry = Math.abs(evt.shiftKey ? (x - cx) : (y - cy)); const ry = Math.abs(evt.shiftKey ? (x - cx) : (y - cy));
shape.setAttributeNS(null, 'ry', ry); shape.setAttribute('ry', ry);
break; break;
} }
case 'fhellipse': case 'fhellipse':
@ -2380,7 +2380,7 @@ const mouseMove = function (evt) {
// Fallthrough // Fallthrough
case 'fhpath': { case 'fhpath': {
// dAttr += + realX + ',' + realY + ' '; // dAttr += + realX + ',' + realY + ' ';
// shape.setAttributeNS(null, 'points', dAttr); // shape.setAttribute('points', dAttr);
end.x = realX; end.y = realY; end.x = realX; end.y = realY;
if (controllPoint2.x && controllPoint2.y) { if (controllPoint2.x && controllPoint2.y) {
for (i = 0; i < STEP_COUNT - 1; i++) { for (i = 0; i < STEP_COUNT - 1; i++) {

View File

@ -288,7 +288,7 @@ export default function ($) {
const svgroot = document.createElementNS(svgns, 'svg'); const svgroot = document.createElementNS(svgns, 'svg');
// Per https://www.w3.org/TR/xml-names11/#defaulting, the namespace for // Per https://www.w3.org/TR/xml-names11/#defaulting, the namespace for
// attributes should have no value. // attributes should have no value.
svgroot.setAttributeNS(null, 'viewBox', [0, 0, iconW, iconH].join(' ')); svgroot.setAttribute('viewBox', [0, 0, iconW, iconH].join(' '));
let svg = elem.getElementsByTagNameNS(svgns, 'svg')[0]; let svg = elem.getElementsByTagNameNS(svgns, 'svg')[0];

View File

@ -15155,12 +15155,12 @@
if (iswebkit) { if (iswebkit) {
delayedStroke = function delayedStroke(ele) { delayedStroke = function delayedStroke(ele) {
var _stroke = ele.getAttributeNS(null, 'stroke'); var _stroke = ele.getAttribute('stroke');
ele.removeAttributeNS(null, 'stroke'); // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker ele.removeAttribute('stroke'); // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker
if (_stroke !== null) setTimeout(function () { if (_stroke !== null) setTimeout(function () {
ele.setAttributeNS(null, 'stroke', _stroke); ele.setAttribute('stroke', _stroke);
}, 0); }, 0);
}; };
} }
@ -15686,8 +15686,8 @@
y2 = xya.y; y2 = xya.y;
} }
shape.setAttributeNS(null, 'x2', x2); shape.setAttribute('x2', x2);
shape.setAttributeNS(null, 'y2', y2); shape.setAttribute('y2', y2);
break; break;
} }
@ -15741,7 +15741,7 @@
rad = snapToGrid(rad); rad = snapToGrid(rad);
} }
shape.setAttributeNS(null, 'r', rad); shape.setAttribute('r', rad);
break; break;
} }
@ -15759,9 +15759,9 @@
cy = snapToGrid(cy); cy = snapToGrid(cy);
} }
shape.setAttributeNS(null, 'rx', Math.abs(x - cx)); shape.setAttribute('rx', Math.abs(x - cx));
var ry = Math.abs(evt.shiftKey ? x - cx : y - cy); var ry = Math.abs(evt.shiftKey ? x - cx : y - cy);
shape.setAttributeNS(null, 'ry', ry); shape.setAttribute('ry', ry);
break; break;
} }
@ -15778,7 +15778,7 @@
case 'fhpath': case 'fhpath':
{ {
// dAttr += + realX + ',' + realY + ' '; // dAttr += + realX + ',' + realY + ' ';
// shape.setAttributeNS(null, 'points', dAttr); // shape.setAttribute('points', dAttr);
end.x = realX; end.x = realX;
end.y = realY; end.y = realY;
@ -22004,7 +22004,7 @@
var svgroot = document.createElementNS(svgns, 'svg'); // Per https://www.w3.org/TR/xml-names11/#defaulting, the namespace for var svgroot = document.createElementNS(svgns, 'svg'); // Per https://www.w3.org/TR/xml-names11/#defaulting, the namespace for
// attributes should have no value. // attributes should have no value.
svgroot.setAttributeNS(null, 'viewBox', [0, 0, iconW, iconH].join(' ')); svgroot.setAttribute('viewBox', [0, 0, iconW, iconH].join(' '));
var svg = elem.getElementsByTagNameNS(svgns, 'svg')[0]; // Make flexible by converting width/height to viewBox var svg = elem.getElementsByTagNameNS(svgns, 'svg')[0]; // Make flexible by converting width/height to viewBox
var w = svg.getAttribute('width'); var w = svg.getAttribute('width');

View File

@ -15155,12 +15155,12 @@
if (iswebkit) { if (iswebkit) {
delayedStroke = function delayedStroke(ele) { delayedStroke = function delayedStroke(ele) {
var _stroke = ele.getAttributeNS(null, 'stroke'); var _stroke = ele.getAttribute('stroke');
ele.removeAttributeNS(null, 'stroke'); // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker ele.removeAttribute('stroke'); // Re-apply stroke after delay. Anything higher than 1 seems to cause flicker
if (_stroke !== null) setTimeout(function () { if (_stroke !== null) setTimeout(function () {
ele.setAttributeNS(null, 'stroke', _stroke); ele.setAttribute('stroke', _stroke);
}, 0); }, 0);
}; };
} }
@ -15686,8 +15686,8 @@
y2 = xya.y; y2 = xya.y;
} }
shape.setAttributeNS(null, 'x2', x2); shape.setAttribute('x2', x2);
shape.setAttributeNS(null, 'y2', y2); shape.setAttribute('y2', y2);
break; break;
} }
@ -15741,7 +15741,7 @@
rad = snapToGrid(rad); rad = snapToGrid(rad);
} }
shape.setAttributeNS(null, 'r', rad); shape.setAttribute('r', rad);
break; break;
} }
@ -15759,9 +15759,9 @@
cy = snapToGrid(cy); cy = snapToGrid(cy);
} }
shape.setAttributeNS(null, 'rx', Math.abs(x - cx)); shape.setAttribute('rx', Math.abs(x - cx));
var ry = Math.abs(evt.shiftKey ? x - cx : y - cy); var ry = Math.abs(evt.shiftKey ? x - cx : y - cy);
shape.setAttributeNS(null, 'ry', ry); shape.setAttribute('ry', ry);
break; break;
} }
@ -15778,7 +15778,7 @@
case 'fhpath': case 'fhpath':
{ {
// dAttr += + realX + ',' + realY + ' '; // dAttr += + realX + ',' + realY + ' ';
// shape.setAttributeNS(null, 'points', dAttr); // shape.setAttribute('points', dAttr);
end.x = realX; end.x = realX;
end.y = realY; end.y = realY;
@ -22004,7 +22004,7 @@
var svgroot = document.createElementNS(svgns, 'svg'); // Per https://www.w3.org/TR/xml-names11/#defaulting, the namespace for var svgroot = document.createElementNS(svgns, 'svg'); // Per https://www.w3.org/TR/xml-names11/#defaulting, the namespace for
// attributes should have no value. // attributes should have no value.
svgroot.setAttributeNS(null, 'viewBox', [0, 0, iconW, iconH].join(' ')); svgroot.setAttribute('viewBox', [0, 0, iconW, iconH].join(' '));
var svg = elem.getElementsByTagNameNS(svgns, 'svg')[0]; // Make flexible by converting width/height to viewBox var svg = elem.getElementsByTagNameNS(svgns, 'svg')[0]; // Make flexible by converting width/height to viewBox
var w = svg.getAttribute('width'); var w = svg.getAttribute('width');

View File

@ -517,7 +517,7 @@ QUnit.test('Test ChangeElementCommand', function (assert) {
assert.equal(justCalled, 'setHref'); assert.equal(justCalled, 'setHref');
const line = document.createElementNS(NS.SVG, 'line'); const line = document.createElementNS(NS.SVG, 'line');
line.setAttributeNS(null, 'class', 'newClass'); line.setAttribute('class', 'newClass');
change = new history.ChangeElementCommand(line, {class: 'oldClass'}); change = new history.ChangeElementCommand(line, {class: 'oldClass'});
assert.ok(change.unapply); assert.ok(change.unapply);
@ -526,10 +526,10 @@ QUnit.test('Test ChangeElementCommand', function (assert) {
assert.equal(typeof change.apply, typeof function () {}); assert.equal(typeof change.apply, typeof function () {});
change.unapply(); change.unapply();
assert.equal(line.getAttributeNS(null, 'class'), 'oldClass'); assert.equal(line.getAttribute('class'), 'oldClass');
change.apply(); change.apply();
assert.equal(line.getAttributeNS(null, 'class'), 'newClass'); assert.equal(line.getAttribute('class'), 'newClass');
tearDown(); tearDown();
}); });

View File

@ -169,7 +169,7 @@ QUnit.test('Test getPathBBox', function (assert) {
assert.expect(3); assert.expect(3);
const doc = utilities.text2xml('<svg></svg>'); const doc = utilities.text2xml('<svg></svg>');
const path = doc.createElementNS(NS.SVG, 'path'); const path = doc.createElementNS(NS.SVG, 'path');
path.setAttributeNS(null, 'd', 'm0,0l5,0l0,5l-5,0l0,-5z'); path.setAttribute('d', 'm0,0l5,0l0,5l-5,0l0,-5z');
const bb = utilities.getPathBBox(path); const bb = utilities.getPathBBox(path);
assert.equal(typeof bb, 'object', 'BBox returned object'); assert.equal(typeof bb, 'object', 'BBox returned object');
assert.ok(bb.x && !isNaN(bb.x)); assert.ok(bb.x && !isNaN(bb.x));
@ -181,7 +181,7 @@ QUnit.test('Test getPathDFromSegments', function (assert) {
const doc = utilities.text2xml('<svg></svg>'); const doc = utilities.text2xml('<svg></svg>');
const path = doc.createElementNS(NS.SVG, 'path'); const path = doc.createElementNS(NS.SVG, 'path');
path.setAttributeNS(null, 'd', 'm0,0l5,0l0,5l-5,0l0,-5z'); path.setAttribute('d', 'm0,0l5,0l0,5l-5,0l0,-5z');
let d = getPathDFromSegments([ let d = getPathDFromSegments([
['M', [1, 2]], ['M', [1, 2]],
['Z', []] ['Z', []]