Skip to content

Commit 913b8fc

Browse files
committed
fix(ie): avoid top level Promise
1 parent d7f6646 commit 913b8fc

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

src/client/client-task-queue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const flush = () => {
8585
}
8686
};
8787

88-
export const tick = /*@__PURE__*/Promise.resolve();
88+
export const nextTick = /*@__PURE__*/(cb: () => void) => Promise.resolve().then(cb);
8989

9090
export const readTask = /*@__PURE__*/queueTask(queueDomReads);
9191

src/hydrate/platform/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const writeTask = (cb: Function) => {
5555
});
5656
};
5757

58-
export const tick = Promise.resolve();
58+
export const nextTick = /*@__PURE__*/(cb: () => void) => Promise.resolve().then(cb);
5959

6060
export const consoleError = (e: any) => {
6161
if (e != null) {

src/runtime/connected-callback.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { addEventListeners } from './host-listener';
33
import { addStyle } from './styles';
44
import { BUILD } from '@build-conditionals';
55
import { CMP_FLAGS, HOST_FLAGS, MEMBER_FLAGS } from '@utils';
6-
import { doc, getHostRef, plt, supportsShadowDom, tick } from '@platform';
6+
import { doc, getHostRef, nextTick, plt, supportsShadowDom } from '@platform';
77
import { HYDRATE_ID, NODE_TYPE, PLATFORM_FLAGS } from './runtime-constants';
88
import { initializeClientHydrate } from './client-hydrate';
99
import { initializeComponent } from './initialize-component';
@@ -95,7 +95,7 @@ export const connectedCallback = (elm: d.HostElement, cmpMeta: d.ComponentRuntim
9595
// angular sets attribute AFTER connectCallback
9696
// https://github.com/angular/angular/issues/18909
9797
// https://github.com/angular/angular/issues/19940
98-
tick.then(() => initializeComponent(elm, hostRef, cmpMeta));
98+
nextTick(() => initializeComponent(elm, hostRef, cmpMeta));
9999

100100
} else {
101101
initializeComponent(elm, hostRef, cmpMeta);

src/runtime/context.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Context, doc, getAssetPath, readTask, tick, win, writeTask } from '@platform';
1+
import { Context, doc, getAssetPath, readTask, nextTick, win, writeTask } from '@platform';
22
import { BUILD } from '@build-conditionals';
33

44
export const getContext = (_elm: HTMLElement, context: string) => {
@@ -19,7 +19,11 @@ export const getContext = (_elm: HTMLElement, context: string) => {
1919
return {
2020
write: writeTask,
2121
read: readTask,
22-
tick
22+
tick: {
23+
then(cb: () => void) {
24+
return nextTick(cb);
25+
}
26+
}
2327
};
2428
}
2529
return undefined;

src/testing/task-queue.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@ export function resetTaskQueue() {
2424
}
2525

2626

27-
export const tick = {
28-
then(cb: Function) {
29-
queuedTicks.push(cb);
30-
}
27+
export const nextTick = (cb: Function) => {
28+
queuedTicks.push(cb);
3129
};
3230

33-
3431
export function flushTicks() {
3532
return new Promise((resolve, reject) => {
3633

0 commit comments

Comments
 (0)