- Refactoring: Avoid redundant use of *AttributeNS methods with
`null` value; just use *Attribute methods without namespace
This commit is contained in:
@@ -220,7 +220,7 @@ export default {
|
||||
let y = opts.mouse_y;
|
||||
const {cx, cy, fill, strokecolor, strokeWidth, sides} = c, // {orient} = c,
|
||||
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 circumradius = inradius * sec(Math.PI / sides);
|
||||
@@ -234,12 +234,12 @@ export default {
|
||||
}
|
||||
|
||||
// const poly = newFO.createElementNS(NS.SVG, 'polygon');
|
||||
newFO.setAttributeNS(null, 'points', points);
|
||||
newFO.setAttributeNS(null, 'fill', fill);
|
||||
newFO.setAttributeNS(null, 'stroke', strokecolor);
|
||||
newFO.setAttributeNS(null, 'stroke-width', strokeWidth);
|
||||
// newFO.setAttributeNS(null, 'transform', 'rotate(-90)');
|
||||
// const shape = newFO.getAttributeNS(null, 'shape');
|
||||
newFO.setAttribute('points', points);
|
||||
newFO.setAttribute('fill', fill);
|
||||
newFO.setAttribute('stroke', strokecolor);
|
||||
newFO.setAttribute('stroke-width', strokeWidth);
|
||||
// newFO.setAttribute('transform', 'rotate(-90)');
|
||||
// const shape = newFO.getAttribute('shape');
|
||||
// newFO.append(poly);
|
||||
// DrawPoly(cx, cy, sides, edg, orient);
|
||||
return {
|
||||
@@ -266,7 +266,7 @@ export default {
|
||||
let i = selElems.length;
|
||||
while (i--) {
|
||||
const elem = selElems[i];
|
||||
if (elem && elem.getAttributeNS(null, 'shape') === 'regularPoly') {
|
||||
if (elem && elem.getAttribute('shape') === 'regularPoly') {
|
||||
if (opts.selectedElement && !opts.multiselected) {
|
||||
$('#polySides').val(elem.getAttribute('sides'));
|
||||
|
||||
|
||||
@@ -153,8 +153,8 @@ export default {
|
||||
const {cx, cy, fill, strokecolor, strokeWidth, radialshift, point, orient} = c,
|
||||
circumradius = (Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy))) / 1.5,
|
||||
inradius = circumradius / document.getElementById('starRadiusMulitplier').value;
|
||||
newFO.setAttributeNS(null, 'r', circumradius);
|
||||
newFO.setAttributeNS(null, 'r2', inradius);
|
||||
newFO.setAttribute('r', circumradius);
|
||||
newFO.setAttribute('r2', inradius);
|
||||
|
||||
let polyPoints = '';
|
||||
for (let s = 0; point >= s; s++) {
|
||||
@@ -185,11 +185,11 @@ export default {
|
||||
polyPoints += x + ',' + y + ' ';
|
||||
}
|
||||
}
|
||||
newFO.setAttributeNS(null, 'points', polyPoints);
|
||||
newFO.setAttributeNS(null, 'fill', fill);
|
||||
newFO.setAttributeNS(null, 'stroke', strokecolor);
|
||||
newFO.setAttributeNS(null, 'stroke-width', strokeWidth);
|
||||
/* const shape = */ newFO.getAttributeNS(null, 'shape');
|
||||
newFO.setAttribute('points', polyPoints);
|
||||
newFO.setAttribute('fill', fill);
|
||||
newFO.setAttribute('stroke', strokecolor);
|
||||
newFO.setAttribute('stroke-width', strokeWidth);
|
||||
/* const shape = */ newFO.getAttribute('shape');
|
||||
|
||||
return {
|
||||
started: true
|
||||
@@ -213,7 +213,7 @@ export default {
|
||||
let i = selElems.length;
|
||||
while (i--) {
|
||||
const elem = selElems[i];
|
||||
if (elem && elem.getAttributeNS(null, 'shape') === 'star') {
|
||||
if (elem && elem.getAttribute('shape') === 'star') {
|
||||
if (opts.selectedElement && !opts.multiselected) {
|
||||
// $('#starRadiusMulitplier').val(elem.getAttribute('r2'));
|
||||
$('#starNumPoints').val(elem.getAttribute('point'));
|
||||
|
||||
@@ -1850,10 +1850,10 @@ const mouseDown = function (evt) {
|
||||
let delayedStroke;
|
||||
if (iswebkit) {
|
||||
delayedStroke = function (ele) {
|
||||
const _stroke = ele.getAttributeNS(null, 'stroke');
|
||||
ele.removeAttributeNS(null, 'stroke');
|
||||
const _stroke = ele.getAttribute('stroke');
|
||||
ele.removeAttribute('stroke');
|
||||
// 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';
|
||||
@@ -2308,8 +2308,8 @@ const mouseMove = function (evt) {
|
||||
y2 = xya.y;
|
||||
}
|
||||
|
||||
shape.setAttributeNS(null, 'x2', x2);
|
||||
shape.setAttributeNS(null, 'y2', y2);
|
||||
shape.setAttribute('x2', x2);
|
||||
shape.setAttribute('y2', y2);
|
||||
break;
|
||||
} case 'foreignObject':
|
||||
// fall through
|
||||
@@ -2354,7 +2354,7 @@ const mouseMove = function (evt) {
|
||||
if (curConfig.gridSnapping) {
|
||||
rad = snapToGrid(rad);
|
||||
}
|
||||
shape.setAttributeNS(null, 'r', rad);
|
||||
shape.setAttribute('r', rad);
|
||||
break;
|
||||
} case 'ellipse': {
|
||||
c = $(shape).attr(['cx', 'cy']);
|
||||
@@ -2365,9 +2365,9 @@ const mouseMove = function (evt) {
|
||||
y = snapToGrid(y);
|
||||
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));
|
||||
shape.setAttributeNS(null, 'ry', ry);
|
||||
shape.setAttribute('ry', ry);
|
||||
break;
|
||||
}
|
||||
case 'fhellipse':
|
||||
@@ -2380,7 +2380,7 @@ const mouseMove = function (evt) {
|
||||
// Fallthrough
|
||||
case 'fhpath': {
|
||||
// dAttr += + realX + ',' + realY + ' ';
|
||||
// shape.setAttributeNS(null, 'points', dAttr);
|
||||
// shape.setAttribute('points', dAttr);
|
||||
end.x = realX; end.y = realY;
|
||||
if (controllPoint2.x && controllPoint2.y) {
|
||||
for (i = 0; i < STEP_COUNT - 1; i++) {
|
||||
|
||||
@@ -288,7 +288,7 @@ export default function ($) {
|
||||
const svgroot = document.createElementNS(svgns, 'svg');
|
||||
// Per https://www.w3.org/TR/xml-names11/#defaulting, the namespace for
|
||||
// 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];
|
||||
|
||||
|
||||
@@ -15155,12 +15155,12 @@
|
||||
|
||||
if (iswebkit) {
|
||||
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 () {
|
||||
ele.setAttributeNS(null, 'stroke', _stroke);
|
||||
ele.setAttribute('stroke', _stroke);
|
||||
}, 0);
|
||||
};
|
||||
}
|
||||
@@ -15686,8 +15686,8 @@
|
||||
y2 = xya.y;
|
||||
}
|
||||
|
||||
shape.setAttributeNS(null, 'x2', x2);
|
||||
shape.setAttributeNS(null, 'y2', y2);
|
||||
shape.setAttribute('x2', x2);
|
||||
shape.setAttribute('y2', y2);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -15741,7 +15741,7 @@
|
||||
rad = snapToGrid(rad);
|
||||
}
|
||||
|
||||
shape.setAttributeNS(null, 'r', rad);
|
||||
shape.setAttribute('r', rad);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -15759,9 +15759,9 @@
|
||||
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);
|
||||
shape.setAttributeNS(null, 'ry', ry);
|
||||
shape.setAttribute('ry', ry);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -15778,7 +15778,7 @@
|
||||
case 'fhpath':
|
||||
{
|
||||
// dAttr += + realX + ',' + realY + ' ';
|
||||
// shape.setAttributeNS(null, 'points', dAttr);
|
||||
// shape.setAttribute('points', dAttr);
|
||||
end.x = realX;
|
||||
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
|
||||
// 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 w = svg.getAttribute('width');
|
||||
|
||||
Reference in New Issue
Block a user