chore: remove deprecated usage of String.prototype.substr (#4699)
This commit is contained in:
parent
c9613ebe09
commit
6bcb7a5ea3
@ -56,14 +56,6 @@ describe('getInnerRange', () => {
|
|||||||
expect(loc2.end.offset).toBe(4)
|
expect(loc2.end.offset).toBe(4)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('at end', () => {
|
|
||||||
const loc2 = getInnerRange(loc1, 4)
|
|
||||||
expect(loc2.start.column).toBe(1)
|
|
||||||
expect(loc2.start.line).toBe(2)
|
|
||||||
expect(loc2.start.offset).toBe(4)
|
|
||||||
expect(loc2.end).toEqual(loc1.end)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('in between', () => {
|
test('in between', () => {
|
||||||
const loc2 = getInnerRange(loc1, 4, 3)
|
const loc2 = getInnerRange(loc1, 4, 3)
|
||||||
expect(loc2.start.column).toBe(1)
|
expect(loc2.start.column).toBe(1)
|
||||||
|
@ -825,9 +825,9 @@ function parseAttribute(
|
|||||||
context,
|
context,
|
||||||
ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END
|
ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END
|
||||||
)
|
)
|
||||||
content = content.substr(1)
|
content = content.slice(1)
|
||||||
} else {
|
} else {
|
||||||
content = content.substr(1, content.length - 2)
|
content = content.slice(1, content.length - 1)
|
||||||
}
|
}
|
||||||
} else if (isSlot) {
|
} else if (isSlot) {
|
||||||
// #1241 special case for v-slot: vuetify relies extensively on slot
|
// #1241 special case for v-slot: vuetify relies extensively on slot
|
||||||
@ -855,7 +855,7 @@ function parseAttribute(
|
|||||||
valueLoc.source = valueLoc.source.slice(1, -1)
|
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')
|
if (isPropShorthand) modifiers.push('prop')
|
||||||
|
|
||||||
// 2.x compat v-bind:foo.sync -> v-model:foo
|
// 2.x compat v-bind:foo.sync -> v-model:foo
|
||||||
@ -1167,7 +1167,7 @@ function isEnd(
|
|||||||
function startsWithEndTagOpen(source: string, tag: string): boolean {
|
function startsWithEndTagOpen(source: string, tag: string): boolean {
|
||||||
return (
|
return (
|
||||||
startsWith(source, '</') &&
|
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] || '>')
|
/[\t\r\n\f />]/.test(source[2 + tag.length] || '>')
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -182,10 +182,10 @@ export const isMemberExpression = __BROWSER__
|
|||||||
export function getInnerRange(
|
export function getInnerRange(
|
||||||
loc: SourceLocation,
|
loc: SourceLocation,
|
||||||
offset: number,
|
offset: number,
|
||||||
length?: number
|
length: number
|
||||||
): SourceLocation {
|
): SourceLocation {
|
||||||
__TEST__ && assert(offset <= loc.source.length)
|
__TEST__ && assert(offset <= loc.source.length)
|
||||||
const source = loc.source.substr(offset, length)
|
const source = loc.source.slice(offset, offset + length)
|
||||||
const newLoc: SourceLocation = {
|
const newLoc: SourceLocation = {
|
||||||
source,
|
source,
|
||||||
start: advancePositionWithClone(loc.start, loc.source, offset),
|
start: advancePositionWithClone(loc.start, loc.source, offset),
|
||||||
|
@ -42,7 +42,7 @@ export const decodeHtml: ParserOptions['decodeEntities'] = (
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
for (let length = maxCRNameLength; !value && length > 0; --length) {
|
for (let length = maxCRNameLength; !value && length > 0; --length) {
|
||||||
name = rawText.substr(1, length)
|
name = rawText.slice(1, 1 + length)
|
||||||
value = (namedCharacterReferences as Record<string, string>)[name]
|
value = (namedCharacterReferences as Record<string, string>)[name]
|
||||||
}
|
}
|
||||||
if (value) {
|
if (value) {
|
||||||
|
7
packages/global.d.ts
vendored
7
packages/global.d.ts
vendored
@ -45,3 +45,10 @@ declare module '@vue/repl' {
|
|||||||
const ReplStore: any
|
const ReplStore: any
|
||||||
export { Repl, ReplStore }
|
export { Repl, ReplStore }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare interface String {
|
||||||
|
/**
|
||||||
|
* @deprecated Please use String.prototype.slice instead of String.prototype.substring in the repository.
|
||||||
|
*/
|
||||||
|
substring(start: number, end?: number): string;
|
||||||
|
}
|
||||||
|
@ -60,7 +60,7 @@ async function fetchVersions(): Promise<string[]> {
|
|||||||
)
|
)
|
||||||
const releases: any[] = await res.json()
|
const releases: any[] = await res.json()
|
||||||
const versions = releases.map(r =>
|
const versions = releases.map(r =>
|
||||||
/^v/.test(r.tag_name) ? r.tag_name.substr(1) : r.tag_name
|
/^v/.test(r.tag_name) ? r.tag_name.slice(1) : r.tag_name
|
||||||
)
|
)
|
||||||
// if the latest version is a pre-release, list all current pre-releases
|
// if the latest version is a pre-release, list all current pre-releases
|
||||||
// otherwise filter out pre-releases
|
// otherwise filter out pre-releases
|
||||||
|
@ -34,14 +34,14 @@ export function escapeHtml(string: unknown) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lastIndex !== index) {
|
if (lastIndex !== index) {
|
||||||
html += str.substring(lastIndex, index)
|
html += str.slice(lastIndex, index)
|
||||||
}
|
}
|
||||||
|
|
||||||
lastIndex = index + 1
|
lastIndex = index + 1
|
||||||
html += escaped
|
html += escaped
|
||||||
}
|
}
|
||||||
|
|
||||||
return lastIndex !== index ? html + str.substring(lastIndex, index) : html
|
return lastIndex !== index ? html + str.slice(lastIndex, index) : html
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/html52/syntax.html#comments
|
// https://www.w3.org/TR/html52/syntax.html#comments
|
||||||
|
Loading…
Reference in New Issue
Block a user