Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace deprecated String.prototype.substr() #3590

Merged
merged 2 commits into from Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Parser.js
Expand Up @@ -922,7 +922,7 @@ export default class Parser {
`Accented Unicode text character "${text[0]}" used in ` +
`math mode`, nucleus);
}
text = unicodeSymbols[text[0]] + text.substr(1);
text = unicodeSymbols[text[0]] + text.slice(1);
}
// Strip off any combining characters
const match = combiningDiacriticalMarksEndRegex.exec(text);
Expand Down
2 changes: 1 addition & 1 deletion src/buildCommon.js
Expand Up @@ -190,7 +190,7 @@ const makeOrd = function<NODETYPE: "spacing" | "mathord" | "textord">(
return makeSymbol(text, fontName, mode, options,
classes.concat(fontClasses));
} else if (ligatures.hasOwnProperty(text) &&
fontName.substr(0, 10) === "Typewriter") {
fontName.slice(0, 10) === "Typewriter") {
// Deconstruct ligatures in monospace fonts (\texttt, \tt).
const parts = [];
for (let i = 0; i < text.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions src/buildMathML.js
Expand Up @@ -32,8 +32,8 @@ export const makeText = function(
if (symbols[mode][text] && symbols[mode][text].replace &&
text.charCodeAt(0) !== 0xD835 &&
!(ligatures.hasOwnProperty(text) && options &&
((options.fontFamily && options.fontFamily.substr(4, 2) === "tt") ||
(options.font && options.font.substr(4, 2) === "tt")))) {
((options.fontFamily && options.fontFamily.slice(4, 6) === "tt") ||
(options.font && options.font.slice(4, 6) === "tt")))) {
text = symbols[mode][text].replace;
}

Expand Down
2 changes: 1 addition & 1 deletion src/environments/array.js
Expand Up @@ -256,7 +256,7 @@ function parseArray(
// Decides on a style for cells in an array according to whether the given
// environment name starts with the letter 'd'.
function dCellStyle(envName): StyleStr {
if (envName.substr(0, 1) === "d") {
if (envName.slice(0, 1) === "d") {
return "display";
} else {
return "text";
Expand Down
2 changes: 1 addition & 1 deletion src/functions/enclose.js
Expand Up @@ -20,7 +20,7 @@ const htmlBuilder = (group, options) => {
const inner = buildCommon.wrapFragment(
html.buildGroup(group.body, options), options);

const label = group.label.substr(1);
const label = group.label.slice(1);
let scale = options.sizeMultiplier;
let img;
let imgShift = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/functions/mclass.js
Expand Up @@ -75,7 +75,7 @@ defineFunction({
return {
type: "mclass",
mode: parser.mode,
mclass: "m" + funcName.substr(5), // TODO(kevinb): don't prefix with 'm'
mclass: "m" + funcName.slice(5), // TODO(kevinb): don't prefix with 'm'
body: ordargument(body),
isCharacterBox: utils.isCharacterBox(body),
};
Expand Down
2 changes: 1 addition & 1 deletion src/functions/op.js
Expand Up @@ -61,7 +61,7 @@ export const htmlBuilder: HtmlBuilderSupSub<"op"> = (grp, options) => {
if (group.name === "\\oiint" || group.name === "\\oiiint") {
// No font glyphs yet, so use a glyph w/o the oval.
// TODO: When font glyphs are available, delete this code.
stash = group.name.substr(1);
stash = group.name.slice(1);
group.name = stash === "oiint" ? "\\iint" : "\\iiint";
}

Expand Down
2 changes: 1 addition & 1 deletion src/macros.js
Expand Up @@ -447,7 +447,7 @@ defineMacro("\\dots", function(context) {
const next = context.expandAfterFuture().text;
if (next in dotsByToken) {
thedots = dotsByToken[next];
} else if (next.substr(0, 4) === '\\not') {
} else if (next.slice(0, 4) === '\\not') {
thedots = '\\dotsb';
} else if (next in symbols.math) {
if (utils.contains(['bin', 'rel'], symbols.math[next].group)) {
Expand Down
2 changes: 1 addition & 1 deletion src/stretchy.js
Expand Up @@ -191,7 +191,7 @@ const svgSpan = function(
height: number,
} {
let viewBoxWidth = 400000; // default
const label = group.label.substr(1);
const label = group.label.slice(1);
if (utils.contains(["widehat", "widecheck", "widetilde", "utilde"],
label)) {
// Each type in the `if` statement corresponds to one of the ParseNode
Expand Down