chore: remove deprecated usage of String.prototype.substr (#4699)

This commit is contained in:
Che Guevara
2021-10-09 00:31:34 +08:00
committed by GitHub
parent c9613ebe09
commit 6bcb7a5ea3
7 changed files with 17 additions and 18 deletions

View File

@@ -825,9 +825,9 @@ function parseAttribute(
context,
ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END
)
content = content.substr(1)
content = content.slice(1)
} else {
content = content.substr(1, content.length - 2)
content = content.slice(1, content.length - 1)
}
} else if (isSlot) {
// #1241 special case for v-slot: vuetify relies extensively on slot
@@ -855,7 +855,7 @@ function parseAttribute(
valueLoc.source = valueLoc.source.slice(1, -1)
}
const modifiers = match[3] ? match[3].substr(1).split('.') : []
const modifiers = match[3] ? match[3].slice(1).split('.') : []
if (isPropShorthand) modifiers.push('prop')
// 2.x compat v-bind:foo.sync -> v-model:foo
@@ -1167,7 +1167,7 @@ function isEnd(
function startsWithEndTagOpen(source: string, tag: string): boolean {
return (
startsWith(source, '</') &&
source.substr(2, tag.length).toLowerCase() === tag.toLowerCase() &&
source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() &&
/[\t\r\n\f />]/.test(source[2 + tag.length] || '>')
)
}

View File

@@ -182,10 +182,10 @@ export const isMemberExpression = __BROWSER__
export function getInnerRange(
loc: SourceLocation,
offset: number,
length?: number
length: number
): SourceLocation {
__TEST__ && assert(offset <= loc.source.length)
const source = loc.source.substr(offset, length)
const source = loc.source.slice(offset, offset + length)
const newLoc: SourceLocation = {
source,
start: advancePositionWithClone(loc.start, loc.source, offset),