From 84a65cf788a2776bdce9e50b1cb0745367073128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=A1ko=20Hevery?= Date: Wed, 1 Mar 2017 15:18:10 -0800 Subject: [PATCH] refactor: remove `global` from facade/lang (#14837) --- modules/@angular/core/src/application_ref.ts | 3 +- .../change_detection/change_detection_util.ts | 3 +- modules/@angular/core/src/core.ts | 2 +- .../@angular/core/src/core_private_export.ts | 1 + .../@angular/core/src/linker/query_list.ts | 2 +- modules/@angular/core/src/profile/wtf_impl.ts | 2 +- .../src/reflection/reflection_capabilities.ts | 6 +- .../core/src/testability/testability.ts | 2 +- modules/@angular/core/src/util.ts | 41 +++++++++- modules/@angular/core/src/util/decorators.ts | 5 +- .../core/test/change_detection/iterable.ts | 2 +- .../system_ng_module_factory_loader_spec.ts | 8 +- .../core/test/testability/testability_spec.ts | 2 +- .../core/test/util/decorators_spec.ts | 7 +- .../@angular/core/test/zone/ng_zone_spec.ts | 3 +- .../core/testing/component_fixture.ts | 5 +- .../@angular/core/testing/testing_internal.ts | 2 +- modules/@angular/facade/src/lang.ts | 79 ------------------- .../resource_loader/resource_loader_cache.ts | 2 +- .../src/browser/browser_adapter.ts | 3 +- .../src/browser/testability.ts | 12 +-- .../test/browser/tools/spies.ts | 4 +- .../platform-browser/testing/browser_util.ts | 4 +- .../platform-browser/testing/matchers.ts | 3 +- .../@angular/platform-server/src/location.ts | 5 +- .../platform-server/src/parse5_adapter.ts | 3 +- 26 files changed, 88 insertions(+), 123 deletions(-) diff --git a/modules/@angular/core/src/application_ref.ts b/modules/@angular/core/src/application_ref.ts index f1a287f3f9..b5204d7c72 100644 --- a/modules/@angular/core/src/application_ref.ts +++ b/modules/@angular/core/src/application_ref.ts @@ -14,7 +14,8 @@ import {merge} from 'rxjs/observable/merge'; import {share} from 'rxjs/operator/share'; import {ErrorHandler} from '../src/error_handler'; -import {scheduleMicroTask, stringify} from '../src/facade/lang'; +import {stringify} from '../src/facade/lang'; +import {scheduleMicroTask} from '../src/util'; import {isPromise} from '../src/util/lang'; import {ApplicationInitStatus} from './application_init'; diff --git a/modules/@angular/core/src/change_detection/change_detection_util.ts b/modules/@angular/core/src/change_detection/change_detection_util.ts index 5f77fe19e9..b672dc5a38 100644 --- a/modules/@angular/core/src/change_detection/change_detection_util.ts +++ b/modules/@angular/core/src/change_detection/change_detection_util.ts @@ -6,7 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {getSymbolIterator, isJsObject, isPrimitive, looseIdentical} from '../facade/lang'; +import {isJsObject, isPrimitive, looseIdentical} from '../facade/lang'; +import {getSymbolIterator} from '../util'; export {looseIdentical} from '../facade/lang'; diff --git a/modules/@angular/core/src/core.ts b/modules/@angular/core/src/core.ts index 96fca7ebc5..772da782a8 100644 --- a/modules/@angular/core/src/core.ts +++ b/modules/@angular/core/src/core.ts @@ -13,7 +13,7 @@ */ export * from './metadata'; export * from './version'; -export * from './util'; +export {Class, ClassDefinition, TypeDecorator} from './util/decorators'; export * from './di'; export {createPlatform, assertPlatform, destroyPlatform, getPlatform, PlatformRef, ApplicationRef, enableProdMode, isDevMode, createPlatformFactory, NgProbeToken} from './application_ref'; export {APP_ID, PACKAGE_ROOT_URL, PLATFORM_INITIALIZER, PLATFORM_ID, APP_BOOTSTRAP_LISTENER} from './application_tokens'; diff --git a/modules/@angular/core/src/core_private_export.ts b/modules/@angular/core/src/core_private_export.ts index f77da1c1e8..20e09182a4 100644 --- a/modules/@angular/core/src/core_private_export.ts +++ b/modules/@angular/core/src/core_private_export.ts @@ -23,5 +23,6 @@ export {ReflectionCapabilities as ɵReflectionCapabilities} from './reflection/r export {ReflectorReader as ɵReflectorReader} from './reflection/reflector_reader'; export {GetterFn as ɵGetterFn, MethodFn as ɵMethodFn, SetterFn as ɵSetterFn} from './reflection/types'; export {DirectRenderer as ɵDirectRenderer, RenderDebugInfo as ɵRenderDebugInfo} from './render/api'; +export {global as ɵglobal} from './util'; export {makeDecorator as ɵmakeDecorator} from './util/decorators'; export {isObservable as ɵisObservable, isPromise as ɵisPromise, merge as ɵmerge} from './util/lang'; diff --git a/modules/@angular/core/src/linker/query_list.ts b/modules/@angular/core/src/linker/query_list.ts index 13b02bfb2c..a5f5888806 100644 --- a/modules/@angular/core/src/linker/query_list.ts +++ b/modules/@angular/core/src/linker/query_list.ts @@ -9,7 +9,7 @@ import {Observable} from 'rxjs/Observable'; import {EventEmitter} from '../event_emitter'; -import {getSymbolIterator} from '../facade/lang'; +import {getSymbolIterator} from '../util'; /** diff --git a/modules/@angular/core/src/profile/wtf_impl.ts b/modules/@angular/core/src/profile/wtf_impl.ts index da66029e99..8d03568e2c 100644 --- a/modules/@angular/core/src/profile/wtf_impl.ts +++ b/modules/@angular/core/src/profile/wtf_impl.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {global} from '../facade/lang'; +import {global} from '../util'; /** * A scope function for the Web Tracing Framework (WTF). diff --git a/modules/@angular/core/src/reflection/reflection_capabilities.ts b/modules/@angular/core/src/reflection/reflection_capabilities.ts index 980194e500..063d9e7fa5 100644 --- a/modules/@angular/core/src/reflection/reflection_capabilities.ts +++ b/modules/@angular/core/src/reflection/reflection_capabilities.ts @@ -6,9 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {global, isPresent, stringify} from '../facade/lang'; +import {isPresent, stringify} from '../facade/lang'; import {Type, isType} from '../type'; - +import {global} from '../util'; import {PlatformReflectionCapabilities} from './platform_reflection_capabilities'; import {GetterFn, MethodFn, SetterFn} from './types'; @@ -21,7 +21,7 @@ export const DELEGATE_CTOR = export class ReflectionCapabilities implements PlatformReflectionCapabilities { private _reflect: any; - constructor(reflect?: any) { this._reflect = reflect || global.Reflect; } + constructor(reflect?: any) { this._reflect = reflect || global['Reflect']; } isReflectionEnabled(): boolean { return true; } diff --git a/modules/@angular/core/src/testability/testability.ts b/modules/@angular/core/src/testability/testability.ts index 3d671463cd..3360c574f9 100644 --- a/modules/@angular/core/src/testability/testability.ts +++ b/modules/@angular/core/src/testability/testability.ts @@ -7,7 +7,7 @@ */ import {Injectable} from '../di'; -import {scheduleMicroTask} from '../facade/lang'; +import {scheduleMicroTask} from '../util'; import {NgZone} from '../zone/ng_zone'; /** diff --git a/modules/@angular/core/src/util.ts b/modules/@angular/core/src/util.ts index 2213e43a7d..bba986bac8 100644 --- a/modules/@angular/core/src/util.ts +++ b/modules/@angular/core/src/util.ts @@ -6,5 +6,42 @@ * found in the LICENSE file at https://angular.io/license */ -// Public API for util -export {Class, ClassDefinition, TypeDecorator} from './util/decorators'; +// TODO(jteplitz602): Load WorkerGlobalScope from lib.webworker.d.ts file #3492 +declare var WorkerGlobalScope: any /** TODO #9100 */; +// CommonJS / Node have global context exposed as "global" variable. +// We don't want to include the whole node.d.ts this this compilation unit so we'll just fake +// the global "global" var for now. +declare var global: any /** TODO #9100 */; +const __window = typeof window !== 'undefined' && window; +const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && + self instanceof WorkerGlobalScope && self; +const __global = typeof global !== 'undefined' && global; +const _global: {[name: string]: any} = __window || __global || __self; +export {_global as global}; + +// When Symbol.iterator doesn't exist, retrieves the key used in es6-shim +declare const Symbol: any; +let _symbolIterator: any = null; +export function getSymbolIterator(): string|symbol { + if (!_symbolIterator) { + var Symbol = _global['Symbol']; + if (Symbol && Symbol.iterator) { + _symbolIterator = Symbol.iterator; + } else { + // es6-shim specific logic + const keys = Object.getOwnPropertyNames(Map.prototype); + for (let i = 0; i < keys.length; ++i) { + const key = keys[i]; + if (key !== 'entries' && key !== 'size' && + (Map as any).prototype[key] === Map.prototype['entries']) { + _symbolIterator = key; + } + } + } + } + return _symbolIterator; +} + +export function scheduleMicroTask(fn: Function) { + Zone.current.scheduleMicroTask('scheduleMicrotask', fn); +} diff --git a/modules/@angular/core/src/util/decorators.ts b/modules/@angular/core/src/util/decorators.ts index cfb24c9118..36c76cffa7 100644 --- a/modules/@angular/core/src/util/decorators.ts +++ b/modules/@angular/core/src/util/decorators.ts @@ -6,11 +6,12 @@ * found in the LICENSE file at https://angular.io/license */ -import {global, stringify} from '../facade/lang'; +import {stringify} from '../facade/lang'; import {Type} from '../type'; +import {global} from '../util'; let _nextClassId = 0; -const Reflect = global.Reflect; +const Reflect = global['Reflect']; /** * Declares the interface to be used with {@link Class}. diff --git a/modules/@angular/core/test/change_detection/iterable.ts b/modules/@angular/core/test/change_detection/iterable.ts index 33385ba3e3..b78de13bf9 100644 --- a/modules/@angular/core/test/change_detection/iterable.ts +++ b/modules/@angular/core/test/change_detection/iterable.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {getSymbolIterator} from '../../src/facade/lang'; +import {getSymbolIterator} from '@angular/core/src/util'; export class TestIterable { list: number[]; diff --git a/modules/@angular/core/test/linker/system_ng_module_factory_loader_spec.ts b/modules/@angular/core/test/linker/system_ng_module_factory_loader_spec.ts index fe7ae3795f..780988840f 100644 --- a/modules/@angular/core/test/linker/system_ng_module_factory_loader_spec.ts +++ b/modules/@angular/core/test/linker/system_ng_module_factory_loader_spec.ts @@ -6,8 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {global} from '@angular/common/src/facade/lang'; import {Compiler, SystemJsNgModuleLoader} from '@angular/core'; +import {global} from '@angular/core/src/util'; import {async} from '@angular/core/testing'; import {afterEach, beforeEach, describe, expect, it} from '@angular/core/testing/testing_internal'; @@ -24,14 +24,14 @@ export function main() { describe('SystemJsNgModuleLoader', () => { let oldSystem: any = null; beforeEach(() => { - oldSystem = (global as any).System; - (global as any).System = mockSystem({ + oldSystem = global['System']; + global['System'] = mockSystem({ 'test.ngfactory': {'default': 'test module factory', 'NamedNgFactory': 'test NamedNgFactory'}, 'prefixed/test/suffixed': {'NamedNgFactory': 'test module factory'} }); }); - afterEach(() => { (global as any).System = oldSystem; }); + afterEach(() => { global['System'] = oldSystem; }); it('loads a default factory by appending the factory suffix', async(() => { const loader = new SystemJsNgModuleLoader(new Compiler()); diff --git a/modules/@angular/core/test/testability/testability_spec.ts b/modules/@angular/core/test/testability/testability_spec.ts index f892c51907..ba40f6fa3b 100644 --- a/modules/@angular/core/test/testability/testability_spec.ts +++ b/modules/@angular/core/test/testability/testability_spec.ts @@ -12,7 +12,7 @@ import {Testability} from '@angular/core/src/testability/testability'; import {NgZone} from '@angular/core/src/zone/ng_zone'; import {AsyncTestCompleter, SpyObject, beforeEach, describe, expect, inject, it} from '@angular/core/testing/testing_internal'; -import {scheduleMicroTask} from '../../src/facade/lang'; +import {scheduleMicroTask} from '../../src/util'; diff --git a/modules/@angular/core/test/util/decorators_spec.ts b/modules/@angular/core/test/util/decorators_spec.ts index 7272b05042..3626022f14 100644 --- a/modules/@angular/core/test/util/decorators_spec.ts +++ b/modules/@angular/core/test/util/decorators_spec.ts @@ -8,15 +8,14 @@ import {Inject} from '@angular/core'; import {reflector} from '@angular/core/src/reflection/reflection'; +import {global} from '@angular/core/src/util'; import {Class, makeDecorator, makePropDecorator} from '@angular/core/src/util/decorators'; -import {global} from '../../src/facade/lang'; - class DecoratedParent {} class DecoratedChild extends DecoratedParent {} export function main() { - const Reflect = global.Reflect; + const Reflect = global['Reflect']; const TerminalDecorator = makeDecorator('TerminalDecorator', {terminal: true}); const TestDecorator = makeDecorator( @@ -161,4 +160,4 @@ export function main() { }); }); }); -} \ No newline at end of file +} diff --git a/modules/@angular/core/test/zone/ng_zone_spec.ts b/modules/@angular/core/test/zone/ng_zone_spec.ts index 07b42e756d..0ec55af5b7 100644 --- a/modules/@angular/core/test/zone/ng_zone_spec.ts +++ b/modules/@angular/core/test/zone/ng_zone_spec.ts @@ -10,7 +10,8 @@ import {NgZone} from '@angular/core/src/zone/ng_zone'; import {async, fakeAsync, flushMicrotasks} from '@angular/core/testing'; import {AsyncTestCompleter, Log, beforeEach, describe, expect, inject, it, xit} from '@angular/core/testing/testing_internal'; import {browserDetection} from '@angular/platform-browser/testing/browser_util'; -import {isPresent, scheduleMicroTask} from '../../src/facade/lang'; +import {isPresent} from '../../src/facade/lang'; +import {scheduleMicroTask} from '../../src/util'; const needsLongerTimers = browserDetection.isSlow || browserDetection.isEdge; const resultTimer = 1000; diff --git a/modules/@angular/core/testing/component_fixture.ts b/modules/@angular/core/testing/component_fixture.ts index e9b54233bb..db2ae65b76 100644 --- a/modules/@angular/core/testing/component_fixture.ts +++ b/modules/@angular/core/testing/component_fixture.ts @@ -7,7 +7,6 @@ */ import {ChangeDetectorRef, ComponentRef, DebugElement, ElementRef, NgZone, getDebugNode} from '@angular/core'; -import {scheduleMicroTask} from './facade/lang'; /** @@ -186,3 +185,7 @@ export class ComponentFixture { } } } + +function scheduleMicroTask(fn: Function) { + Zone.current.scheduleMicroTask('scheduleMicrotask', fn); +} diff --git a/modules/@angular/core/testing/testing_internal.ts b/modules/@angular/core/testing/testing_internal.ts index 09b295dd83..080458bda6 100644 --- a/modules/@angular/core/testing/testing_internal.ts +++ b/modules/@angular/core/testing/testing_internal.ts @@ -7,9 +7,9 @@ */ import {ɵisPromise as isPromise, ɵmerge as merge} from '@angular/core'; +import {global} from '@angular/core/src/util'; import {AsyncTestCompleter} from './async_test_completer'; -import {global} from './facade/lang'; import {getTestBed, inject} from './test_bed'; export {AsyncTestCompleter} from './async_test_completer'; diff --git a/modules/@angular/facade/src/lang.ts b/modules/@angular/facade/src/lang.ts index 08a7912d38..b0b0400d07 100644 --- a/modules/@angular/facade/src/lang.ts +++ b/modules/@angular/facade/src/lang.ts @@ -6,68 +6,11 @@ * found in the LICENSE file at https://angular.io/license */ -export interface BrowserNodeGlobal { - Object: typeof Object; - Array: typeof Array; - Map: typeof Map; - Set: typeof Set; - Date: DateConstructor; - RegExp: RegExpConstructor; - JSON: typeof JSON; - Math: any; // typeof Math; - assert(condition: any): void; - Reflect: any; - getAngularTestability: Function; - getAllAngularTestabilities: Function; - getAllAngularRootElements: Function; - frameworkStabilizers: Array; - setTimeout: Function; - clearTimeout: Function; - setInterval: Function; - clearInterval: Function; - encodeURI: Function; -} - -// TODO(jteplitz602): Load WorkerGlobalScope from lib.webworker.d.ts file #3492 -declare var WorkerGlobalScope: any /** TODO #9100 */; -// CommonJS / Node have global context exposed as "global" variable. -// We don't want to include the whole node.d.ts this this compilation unit so we'll just fake -// the global "global" var for now. -declare var global: any /** TODO #9100 */; - -let globalScope: BrowserNodeGlobal; -if (typeof window === 'undefined') { - if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) { - // TODO: Replace any with WorkerGlobalScope from lib.webworker.d.ts #3492 - globalScope = self; - } else { - globalScope = global; - } -} else { - globalScope = window; -} - -export function scheduleMicroTask(fn: Function) { - Zone.current.scheduleMicroTask('scheduleMicrotask', fn); -} - -// Need to declare a new variable for global here since TypeScript -// exports the original value of the symbol. -const _global: BrowserNodeGlobal = globalScope; - -export {_global as global}; export function getTypeNameForDebugging(type: any): string { return type['name'] || typeof type; } -// TODO: remove calls to assert in production environment -// Note: Can't just export this and import in in other files -// as `assert` is a reserved keyword in Dart -_global.assert = function assert(condition) { - // TODO: to be fixed properly via #2830, noop for now -}; - export function isPresent(obj: any): boolean { return obj != null; } @@ -150,28 +93,6 @@ export function setValueOnPath(global: any, path: string, value: any) { obj[parts.shift()] = value; } -// When Symbol.iterator doesn't exist, retrieves the key used in es6-shim -declare const Symbol: any; -let _symbolIterator: any = null; -export function getSymbolIterator(): string|symbol { - if (!_symbolIterator) { - if ((globalScope).Symbol && Symbol.iterator) { - _symbolIterator = Symbol.iterator; - } else { - // es6-shim specific logic - const keys = Object.getOwnPropertyNames(Map.prototype); - for (let i = 0; i < keys.length; ++i) { - const key = keys[i]; - if (key !== 'entries' && key !== 'size' && - (Map as any).prototype[key] === Map.prototype['entries']) { - _symbolIterator = key; - } - } - } - } - return _symbolIterator; -} - export function isPrimitive(obj: any): boolean { return !isJsObject(obj); } diff --git a/modules/@angular/platform-browser-dynamic/src/resource_loader/resource_loader_cache.ts b/modules/@angular/platform-browser-dynamic/src/resource_loader/resource_loader_cache.ts index a0fc6967d1..4fb4d71c90 100644 --- a/modules/@angular/platform-browser-dynamic/src/resource_loader/resource_loader_cache.ts +++ b/modules/@angular/platform-browser-dynamic/src/resource_loader/resource_loader_cache.ts @@ -7,7 +7,7 @@ */ import {ResourceLoader} from '@angular/compiler'; -import {global} from '../facade/lang'; +import {ɵglobal as global} from '@angular/core'; /** * An implementation of ResourceLoader that uses a template cache to avoid doing an actual diff --git a/modules/@angular/platform-browser/src/browser/browser_adapter.ts b/modules/@angular/platform-browser/src/browser/browser_adapter.ts index f16a175a4a..e5288b3fb8 100644 --- a/modules/@angular/platform-browser/src/browser/browser_adapter.ts +++ b/modules/@angular/platform-browser/src/browser/browser_adapter.ts @@ -6,8 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ +import {ɵglobal as global} from '@angular/core'; import {setRootDomAdapter} from '../dom/dom_adapter'; -import {global, isBlank, isPresent, setValueOnPath} from '../facade/lang'; +import {isBlank, isPresent, setValueOnPath} from '../facade/lang'; import {GenericBrowserDomAdapter} from './generic_browser_adapter'; diff --git a/modules/@angular/platform-browser/src/browser/testability.ts b/modules/@angular/platform-browser/src/browser/testability.ts index e64c0c29f6..a415bd8501 100644 --- a/modules/@angular/platform-browser/src/browser/testability.ts +++ b/modules/@angular/platform-browser/src/browser/testability.ts @@ -6,16 +6,16 @@ * found in the LICENSE file at https://angular.io/license */ -import {GetTestability, Testability, TestabilityRegistry, setTestabilityGetter} from '@angular/core'; +import {GetTestability, Testability, TestabilityRegistry, setTestabilityGetter, ɵglobal as global} from '@angular/core'; import {getDOM} from '../dom/dom_adapter'; -import {global, isPresent} from '../facade/lang'; +import {isPresent} from '../facade/lang'; export class BrowserGetTestability implements GetTestability { static init() { setTestabilityGetter(new BrowserGetTestability()); } addToWindow(registry: TestabilityRegistry): void { - global.getAngularTestability = (elem: any, findInAncestors: boolean = true) => { + global['getAngularTestability'] = (elem: any, findInAncestors: boolean = true) => { const testability = registry.findTestabilityInTree(elem, findInAncestors); if (testability == null) { throw new Error('Could not find testability for element.'); @@ -23,12 +23,12 @@ export class BrowserGetTestability implements GetTestability { return testability; }; - global.getAllAngularTestabilities = () => registry.getAllTestabilities(); + global['getAllAngularTestabilities'] = () => registry.getAllTestabilities(); - global.getAllAngularRootElements = () => registry.getAllRootElements(); + global['getAllAngularRootElements'] = () => registry.getAllRootElements(); const whenAllStable = (callback: any /** TODO #9100 */) => { - const testabilities = global.getAllAngularTestabilities(); + const testabilities = global['getAllAngularTestabilities'](); let count = testabilities.length; let didWork = false; const decrement = function(didWork_: any /** TODO #9100 */) { diff --git a/modules/@angular/platform-browser/test/browser/tools/spies.ts b/modules/@angular/platform-browser/test/browser/tools/spies.ts index f6bbab8cee..8312bf7d5a 100644 --- a/modules/@angular/platform-browser/test/browser/tools/spies.ts +++ b/modules/@angular/platform-browser/test/browser/tools/spies.ts @@ -6,12 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import {ReflectiveInjector} from '@angular/core'; +import {ReflectiveInjector, ɵglobal as global} from '@angular/core'; import {ApplicationRef, ApplicationRef_} from '@angular/core/src/application_ref'; import {SpyObject} from '@angular/core/testing/testing_internal'; -import {global} from '../../../src/facade/lang'; - export class SpyApplicationRef extends SpyObject { constructor() { super(ApplicationRef_); } } diff --git a/modules/@angular/platform-browser/testing/browser_util.ts b/modules/@angular/platform-browser/testing/browser_util.ts index aa5e4615c2..07d49a9c2c 100644 --- a/modules/@angular/platform-browser/testing/browser_util.ts +++ b/modules/@angular/platform-browser/testing/browser_util.ts @@ -6,11 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgZone} from '@angular/core'; +import {NgZone, ɵglobal as global} from '@angular/core'; import {ɵgetDOM as getDOM} from '@angular/platform-browser'; -import {global} from './facade/lang'; - export let browserDetection: BrowserDetection; export class BrowserDetection { diff --git a/modules/@angular/platform-browser/testing/matchers.ts b/modules/@angular/platform-browser/testing/matchers.ts index 8bf986f223..8e7cf480ee 100644 --- a/modules/@angular/platform-browser/testing/matchers.ts +++ b/modules/@angular/platform-browser/testing/matchers.ts @@ -7,10 +7,9 @@ */ +import {ɵglobal as global} from '@angular/core'; import {ɵgetDOM as getDOM} from '@angular/platform-browser'; -import {global} from './facade/lang'; - /** diff --git a/modules/@angular/platform-server/src/location.ts b/modules/@angular/platform-server/src/location.ts index c168b8018f..0fe880bac0 100644 --- a/modules/@angular/platform-server/src/location.ts +++ b/modules/@angular/platform-server/src/location.ts @@ -11,7 +11,6 @@ import {Inject, Injectable, Optional} from '@angular/core'; import {DOCUMENT, ɵgetDOM as getDOM} from '@angular/platform-browser'; import {Subject} from 'rxjs/Subject'; import * as url from 'url'; -import {scheduleMicroTask} from './facade/lang'; import {INITIAL_CONFIG, PlatformConfig} from './tokens'; @@ -88,3 +87,7 @@ export class ServerPlatformLocation implements PlatformLocation { back(): void { throw new Error('Not implemented'); } } + +export function scheduleMicroTask(fn: Function) { + Zone.current.scheduleMicroTask('scheduleMicrotask', fn); +} diff --git a/modules/@angular/platform-server/src/parse5_adapter.ts b/modules/@angular/platform-server/src/parse5_adapter.ts index 4d93d11f92..aa52853912 100644 --- a/modules/@angular/platform-server/src/parse5_adapter.ts +++ b/modules/@angular/platform-server/src/parse5_adapter.ts @@ -8,8 +8,9 @@ const parse5 = require('parse5'); +import {ɵglobal as global} from '@angular/core'; import {ɵDomAdapter as DomAdapter, ɵsetRootDomAdapter as setRootDomAdapter} from '@angular/platform-browser'; -import {isPresent, isBlank, global, setValueOnPath} from '../src/facade/lang'; +import {isPresent, isBlank, setValueOnPath} from '../src/facade/lang'; import {SelectorMatcher, CssSelector} from '@angular/compiler'; let treeAdapter: any;