mirror of https://github.com/vuejs/core.git
refactor(runtime-vapor): remove optional chaining syntax (#208)
This commit is contained in:
parent
b3cb392f5c
commit
9346f885b0
|
@ -249,7 +249,7 @@ export const setCurrentInstance = (instance: ComponentInternalInstance) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const unsetCurrentInstance = () => {
|
export const unsetCurrentInstance = () => {
|
||||||
currentInstance?.scope.off()
|
currentInstance && currentInstance.scope.off()
|
||||||
currentInstance = null
|
currentInstance = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,9 @@ export function initSlots(
|
||||||
for (const key in dynamicSlotKeys) {
|
for (const key in dynamicSlotKeys) {
|
||||||
if (
|
if (
|
||||||
!_dynamicSlots.some(slot =>
|
!_dynamicSlots.some(slot =>
|
||||||
isArray(slot) ? slot.some(s => s.name === key) : slot?.name === key,
|
slot && isArray(slot)
|
||||||
|
? slot.some(s => s.name === key)
|
||||||
|
: slot.name === key,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
delete slots[key]
|
delete slots[key]
|
||||||
|
|
|
@ -25,7 +25,7 @@ export function renderEffect(cb: () => void) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance?.isMounted && !instance.isUpdating) {
|
if (instance && instance.isMounted && !instance.isUpdating) {
|
||||||
instance.isUpdating = true
|
instance.isUpdating = true
|
||||||
|
|
||||||
const { bu, u, dirs } = instance
|
const { bu, u, dirs } = instance
|
||||||
|
@ -76,11 +76,11 @@ export function renderEffect(cb: () => void) {
|
||||||
if (instance) job.id = instance.uid
|
if (instance) job.id = instance.uid
|
||||||
queueJob(job)
|
queueJob(job)
|
||||||
}
|
}
|
||||||
if (__DEV__) {
|
if (__DEV__ && instance) {
|
||||||
effect.onTrack = instance?.rtc
|
effect.onTrack = instance.rtc
|
||||||
? e => invokeArrayFns(instance.rtc!, e)
|
? e => invokeArrayFns(instance.rtc!, e)
|
||||||
: void 0
|
: void 0
|
||||||
effect.onTrigger = instance?.rtg
|
effect.onTrigger = instance.rtg
|
||||||
? e => invokeArrayFns(instance.rtg!, e)
|
? e => invokeArrayFns(instance.rtg!, e)
|
||||||
: void 0
|
: void 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,13 +33,14 @@ const resolvedPromise = /*#__PURE__*/ Promise.resolve() as Promise<any>
|
||||||
let currentFlushPromise: Promise<void> | null = null
|
let currentFlushPromise: Promise<void> | null = null
|
||||||
|
|
||||||
export function queueJob(job: SchedulerJob) {
|
export function queueJob(job: SchedulerJob) {
|
||||||
|
let lastOne: SchedulerJob | undefined
|
||||||
if (!(job.flags! & SchedulerJobFlags.QUEUED)) {
|
if (!(job.flags! & SchedulerJobFlags.QUEUED)) {
|
||||||
if (job.id == null) {
|
if (job.id == null) {
|
||||||
queue.push(job)
|
queue.push(job)
|
||||||
} else if (
|
} else if (
|
||||||
// fast path when the job id is larger than the tail
|
// fast path when the job id is larger than the tail
|
||||||
!(job.flags! & SchedulerJobFlags.PRE) &&
|
!(job.flags! & SchedulerJobFlags.PRE) &&
|
||||||
job.id >= (queue[queue.length - 1]?.id || 0)
|
job.id >= (((lastOne = queue[queue.length - 1]) && lastOne.id) || 0)
|
||||||
) {
|
) {
|
||||||
queue.push(job)
|
queue.push(job)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -30,7 +30,10 @@ export function warn(msg: string, ...args: any[]) {
|
||||||
instance,
|
instance,
|
||||||
VaporErrorCodes.APP_WARN_HANDLER,
|
VaporErrorCodes.APP_WARN_HANDLER,
|
||||||
[
|
[
|
||||||
msg + args.map(a => a.toString?.() ?? JSON.stringify(a)).join(''),
|
msg +
|
||||||
|
args
|
||||||
|
.map(a => (a.toString && a.toString()) ?? JSON.stringify(a))
|
||||||
|
.join(''),
|
||||||
instance,
|
instance,
|
||||||
trace
|
trace
|
||||||
.map(
|
.map(
|
||||||
|
|
Loading…
Reference in New Issue