mirror of https://github.com/vuejs/core.git
refactor: remove optional chaining (#10792)
This commit is contained in:
parent
1138e7a715
commit
d00632b1de
|
@ -179,7 +179,7 @@ const tokenizer = new Tokenizer(stack, {
|
||||||
const name = currentOpenTag!.tag
|
const name = currentOpenTag!.tag
|
||||||
currentOpenTag!.isSelfClosing = true
|
currentOpenTag!.isSelfClosing = true
|
||||||
endOpenTag(end)
|
endOpenTag(end)
|
||||||
if (stack[0]?.tag === name) {
|
if (stack[0] && stack[0].tag === name) {
|
||||||
onCloseTag(stack.shift()!, end)
|
onCloseTag(stack.shift()!, end)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -587,14 +587,14 @@ function endOpenTag(end: number) {
|
||||||
|
|
||||||
function onText(content: string, start: number, end: number) {
|
function onText(content: string, start: number, end: number) {
|
||||||
if (__BROWSER__) {
|
if (__BROWSER__) {
|
||||||
const tag = stack[0]?.tag
|
const tag = stack[0] && stack[0].tag
|
||||||
if (tag !== 'script' && tag !== 'style' && content.includes('&')) {
|
if (tag !== 'script' && tag !== 'style' && content.includes('&')) {
|
||||||
content = currentOptions.decodeEntities!(content, false)
|
content = currentOptions.decodeEntities!(content, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const parent = stack[0] || currentRoot
|
const parent = stack[0] || currentRoot
|
||||||
const lastNode = parent.children[parent.children.length - 1]
|
const lastNode = parent.children[parent.children.length - 1]
|
||||||
if (lastNode?.type === NodeTypes.TEXT) {
|
if (lastNode && lastNode.type === NodeTypes.TEXT) {
|
||||||
// merge
|
// merge
|
||||||
lastNode.content += content
|
lastNode.content += content
|
||||||
setLocEnd(lastNode.loc, end)
|
setLocEnd(lastNode.loc, end)
|
||||||
|
@ -771,7 +771,8 @@ function isComponent({ tag, props }: ElementNode): boolean {
|
||||||
tag === 'component' ||
|
tag === 'component' ||
|
||||||
isUpperCase(tag.charCodeAt(0)) ||
|
isUpperCase(tag.charCodeAt(0)) ||
|
||||||
isCoreComponent(tag) ||
|
isCoreComponent(tag) ||
|
||||||
currentOptions.isBuiltInComponent?.(tag) ||
|
(currentOptions.isBuiltInComponent &&
|
||||||
|
currentOptions.isBuiltInComponent(tag)) ||
|
||||||
(currentOptions.isNativeTag && !currentOptions.isNativeTag(tag))
|
(currentOptions.isNativeTag && !currentOptions.isNativeTag(tag))
|
||||||
) {
|
) {
|
||||||
return true
|
return true
|
||||||
|
@ -828,8 +829,8 @@ function condenseWhitespace(
|
||||||
if (node.type === NodeTypes.TEXT) {
|
if (node.type === NodeTypes.TEXT) {
|
||||||
if (!inPre) {
|
if (!inPre) {
|
||||||
if (isAllWhitespace(node.content)) {
|
if (isAllWhitespace(node.content)) {
|
||||||
const prev = nodes[i - 1]?.type
|
const prev = nodes[i - 1] && nodes[i - 1].type
|
||||||
const next = nodes[i + 1]?.type
|
const next = nodes[i + 1] && nodes[i + 1].type
|
||||||
// Remove if:
|
// Remove if:
|
||||||
// - the whitespace is the first or last node, or:
|
// - the whitespace is the first or last node, or:
|
||||||
// - (condense mode) the whitespace is between two comments, or:
|
// - (condense mode) the whitespace is between two comments, or:
|
||||||
|
@ -1063,7 +1064,7 @@ export function baseParse(input: string, options?: ParserOptions): RootNode {
|
||||||
currentOptions.ns === Namespaces.SVG ||
|
currentOptions.ns === Namespaces.SVG ||
|
||||||
currentOptions.ns === Namespaces.MATH_ML
|
currentOptions.ns === Namespaces.MATH_ML
|
||||||
|
|
||||||
const delimiters = options?.delimiters
|
const delimiters = options && options.delimiters
|
||||||
if (delimiters) {
|
if (delimiters) {
|
||||||
tokenizer.delimiterOpen = toCharCodes(delimiters[0])
|
tokenizer.delimiterOpen = toCharCodes(delimiters[0])
|
||||||
tokenizer.delimiterClose = toCharCodes(delimiters[1])
|
tokenizer.delimiterClose = toCharCodes(delimiters[1])
|
||||||
|
|
|
@ -128,7 +128,7 @@ export class ReactiveEffect<T = any> {
|
||||||
if (this.active) {
|
if (this.active) {
|
||||||
preCleanupEffect(this)
|
preCleanupEffect(this)
|
||||||
postCleanupEffect(this)
|
postCleanupEffect(this)
|
||||||
this.onStop?.()
|
this.onStop && this.onStop()
|
||||||
this.active = false
|
this.active = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,5 +146,6 @@ export function trigger(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDepFromReactive(object: any, key: string | number | symbol) {
|
export function getDepFromReactive(object: any, key: string | number | symbol) {
|
||||||
return targetMap.get(object)?.get(key)
|
const depsMap = targetMap.get(object)
|
||||||
|
return depsMap && depsMap.get(key)
|
||||||
}
|
}
|
||||||
|
|
|
@ -479,7 +479,7 @@ function createSuspenseBoundary(
|
||||||
let parentSuspenseId: number | undefined
|
let parentSuspenseId: number | undefined
|
||||||
const isSuspensible = isVNodeSuspensible(vnode)
|
const isSuspensible = isVNodeSuspensible(vnode)
|
||||||
if (isSuspensible) {
|
if (isSuspensible) {
|
||||||
if (parentSuspense?.pendingBranch) {
|
if (parentSuspense && parentSuspense.pendingBranch) {
|
||||||
parentSuspenseId = parentSuspense.pendingId
|
parentSuspenseId = parentSuspense.pendingId
|
||||||
parentSuspense.deps++
|
parentSuspense.deps++
|
||||||
}
|
}
|
||||||
|
@ -898,5 +898,6 @@ function setActiveBranch(suspense: SuspenseBoundary, branch: VNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isVNodeSuspensible(vnode: VNode) {
|
function isVNodeSuspensible(vnode: VNode) {
|
||||||
return vnode.props?.suspensible != null && vnode.props.suspensible !== false
|
const suspensible = vnode.props && vnode.props.suspensible
|
||||||
|
return suspensible != null && suspensible !== false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue