Skip to content

Commit

Permalink
fix(ie): avoid top level Promise
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed May 29, 2019
1 parent d7f6646 commit 913b8fc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/client/client-task-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const flush = () => {
}
};

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/hydrate/platform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const writeTask = (cb: Function) => {
});
};

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

export const consoleError = (e: any) => {
if (e != null) {
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/connected-callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { addEventListeners } from './host-listener';
import { addStyle } from './styles';
import { BUILD } from '@build-conditionals';
import { CMP_FLAGS, HOST_FLAGS, MEMBER_FLAGS } from '@utils';
import { doc, getHostRef, plt, supportsShadowDom, tick } from '@platform';
import { doc, getHostRef, nextTick, plt, supportsShadowDom } from '@platform';
import { HYDRATE_ID, NODE_TYPE, PLATFORM_FLAGS } from './runtime-constants';
import { initializeClientHydrate } from './client-hydrate';
import { initializeComponent } from './initialize-component';
Expand Down Expand Up @@ -95,7 +95,7 @@ export const connectedCallback = (elm: d.HostElement, cmpMeta: d.ComponentRuntim
// angular sets attribute AFTER connectCallback
// https://github.com/angular/angular/issues/18909
// https://github.com/angular/angular/issues/19940
tick.then(() => initializeComponent(elm, hostRef, cmpMeta));
nextTick(() => initializeComponent(elm, hostRef, cmpMeta));

} else {
initializeComponent(elm, hostRef, cmpMeta);
Expand Down
8 changes: 6 additions & 2 deletions src/runtime/context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Context, doc, getAssetPath, readTask, tick, win, writeTask } from '@platform';
import { Context, doc, getAssetPath, readTask, nextTick, win, writeTask } from '@platform';
import { BUILD } from '@build-conditionals';

export const getContext = (_elm: HTMLElement, context: string) => {
Expand All @@ -19,7 +19,11 @@ export const getContext = (_elm: HTMLElement, context: string) => {
return {
write: writeTask,
read: readTask,
tick
tick: {
then(cb: () => void) {
return nextTick(cb);
}
}
};
}
return undefined;
Expand Down
7 changes: 2 additions & 5 deletions src/testing/task-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ export function resetTaskQueue() {
}


export const tick = {
then(cb: Function) {
queuedTicks.push(cb);
}
export const nextTick = (cb: Function) => {
queuedTicks.push(cb);
};


export function flushTicks() {
return new Promise((resolve, reject) => {

Expand Down

0 comments on commit 913b8fc

Please sign in to comment.