diff --git a/packages/core/src/scheduler/scheduler.ts b/packages/core/src/scheduler/scheduler.ts index 23d2bf35..f01d19ff 100644 --- a/packages/core/src/scheduler/scheduler.ts +++ b/packages/core/src/scheduler/scheduler.ts @@ -50,6 +50,7 @@ class Scheduler { [TaskPriority.LOW]: [], }; private deadline = 0; + private lastId = 0; private task: Task = null; private scheduledCallback: WorkLoop = null; private isMessageLoopRunning = false; @@ -76,10 +77,15 @@ class Scheduler { schedule(callback: TaskCallback, options: ScheduleCallbackOptions) { const task = createTask(callback, options); + this.lastId = task.getId(); this.put(task); this.execute(); } + getLastId() { + return this.lastId; + } + detectIsTransition() { return this.task.getIsTransition(); } @@ -242,6 +248,10 @@ class Task { this.forceAsync = forceAsync; } + getId() { + return this.__id; + } + getPriority() { return this.priority; } diff --git a/packages/core/src/start-transition/start-transition.ts b/packages/core/src/start-transition/start-transition.ts index 6bc484ad..c3545a1e 100644 --- a/packages/core/src/start-transition/start-transition.ts +++ b/packages/core/src/start-transition/start-transition.ts @@ -1,3 +1,4 @@ +import { detectIsFunction, illegal } from '../utils'; import { __useLoc as useLoc } from '../internal'; import { type Callback } from '../shared'; import { scheduler } from '../scheduler'; @@ -7,10 +8,17 @@ import { $$scope } from '../scope'; function startTransition(callback: Callback) { const $scope = $$scope(); + const id = scheduler.getLastId(); $scope.setIsTransitionZone(true); try { callback(); + if (id === scheduler.getLastId()) { + const fn = $scope.getOnTransitionEnd(); + + detectIsFunction(fn) && fn(() => false); + illegal('startTransition must plan a new render!'); + } } finally { $scope.setIsTransitionZone(false); }