fix(ivy): support env where requestAnimationFrame is not available (#26779)

PR Close #26779
This commit is contained in:
Marc Laval
2018-10-26 12:27:40 +02:00
committed by Kara Erickson
parent dc2464eaaa
commit 297c54ebb3
9 changed files with 60 additions and 21 deletions

View File

@ -7,6 +7,7 @@
*/
import {devModeEqual} from '../change_detection/change_detection_util';
import {global} from '../util';
import {assertDefined, assertLessThan} from './assert';
import {ACTIVE_INDEX, LContainer} from './interfaces/container';
@ -154,7 +155,10 @@ export function getRootView(target: LViewData | {}): LViewData {
}
export function getRootContext(viewOrComponent: LViewData | {}): RootContext {
return getRootView(viewOrComponent)[CONTEXT] as RootContext;
const rootView = getRootView(viewOrComponent);
ngDevMode &&
assertDefined(rootView[CONTEXT], 'RootView has no context. Perhaps it is disconnected?');
return rootView[CONTEXT] as RootContext;
}
/**
@ -241,3 +245,8 @@ export function getParentInjectorTNode(
}
return parentTNode;
}
export const defaultScheduler =
(typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame || // browser only
setTimeout // everything else
).bind(global);