Skip to content

Commit

Permalink
chore(): Replace deprecated String.prototype.substr() with Array.prot…
Browse files Browse the repository at this point in the history
…otype.slice() (#7696)

String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with slice() which works similarily but isn't deprecated.
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
  • Loading branch information
CommanderRoot authored Feb 20, 2022
1 parent 30c0c19 commit fc902cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ var eventManager = function(target, type, listener, configure, trigger, fromOver
}
return createBatchCommands(events);
} else if (type.indexOf("on") === 0) { // to support things like "onclick" instead of "click"
type = type.substr(2);
type = type.slice(2);
}

// Ensure listener is a function.
Expand Down Expand Up @@ -1368,7 +1368,7 @@ root.gesture = function(conf) {
var dx = touch.move.x - self.x;
var dy = touch.move.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// If touch start.distance from centroid is 0, scale should not be updated.
// If touch start.distance from centroid is 0, scale should not be updated.
// This prevents dividing by 0 in cases where start.distance is oddly 0.
if (start.distance !== 0) {
scale += distance / start.distance;
Expand Down
4 changes: 2 additions & 2 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@
return;
}

var xlink = xlinkAttribute.substr(1),
var xlink = xlinkAttribute.slice(1),
x = el.getAttribute('x') || 0,
y = el.getAttribute('y') || 0,
el2 = elementById(doc, xlink).cloneNode(true),
Expand Down Expand Up @@ -748,7 +748,7 @@
function recursivelyParseGradientsXlink(doc, gradient) {
var gradientsAttrs = ['gradientTransform', 'x1', 'x2', 'y1', 'y2', 'gradientUnits', 'cx', 'cy', 'r', 'fx', 'fy'],
xlinkAttr = 'xlink:href',
xLink = gradient.getAttribute(xlinkAttr).substr(1),
xLink = gradient.getAttribute(xlinkAttr).slice(1),
referencedGradient = elementById(doc, xLink);
if (referencedGradient && referencedGradient.getAttribute(xlinkAttr)) {
recursivelyParseGradientsXlink(doc, referencedGradient);
Expand Down

0 comments on commit fc902cb

Please sign in to comment.