From e11c20541a0678755061daa7cce89084d2a4b6e4 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Thu, 7 May 2015 15:38:57 +0200 Subject: [PATCH] refactor(VmTurnZone): renamed to NgZone BREAKING CHANGE: VmTurnZone has been renamed to NgZone. - The public API has not chnanged, - The "outer" zone is now named "mount" zone (private to NgZone). --- modules/angular2/src/core/application.js | 18 +++--- .../src/core/life_cycle/life_cycle.js | 4 +- .../zone/{vm_turn_zone.cjs => ng_zone.cjs} | 2 +- .../zone/{vm_turn_zone.dart => ng_zone.dart} | 32 +++++----- .../zone/{vm_turn_zone.es6 => ng_zone.es6} | 60 +++++++++---------- .../{vm_turn_zone_mock.js => ng_zone_mock.js} | 6 +- .../src/render/dom/events/event_manager.js | 10 ++-- .../angular2/src/test_lib/test_injector.js | 8 +-- .../{vm_turn_zone_spec.js => ng_zone_spec.js} | 6 +- .../render/dom/events/event_manager_spec.js | 18 +++--- tools/broccoli/trees/node_tree.ts | 2 +- 11 files changed, 83 insertions(+), 83 deletions(-) rename modules/angular2/src/core/zone/{vm_turn_zone.cjs => ng_zone.cjs} (92%) rename modules/angular2/src/core/zone/{vm_turn_zone.dart => ng_zone.dart} (87%) rename modules/angular2/src/core/zone/{vm_turn_zone.es6 => ng_zone.es6} (72%) rename modules/angular2/src/mock/{vm_turn_zone_mock.js => ng_zone_mock.js} (51%) rename modules/angular2/test/core/zone/{vm_turn_zone_spec.js => ng_zone_spec.js} (98%) diff --git a/modules/angular2/src/core/application.js b/modules/angular2/src/core/application.js index 591f005caf..7afcb0169b 100644 --- a/modules/angular2/src/core/application.js +++ b/modules/angular2/src/core/application.js @@ -12,7 +12,7 @@ import {TemplateResolver} from './compiler/template_resolver'; import {DirectiveMetadataReader} from './compiler/directive_metadata_reader'; import {List, ListWrapper} from 'angular2/src/facade/collection'; import {Promise, PromiseWrapper} from 'angular2/src/facade/async'; -import {VmTurnZone} from 'angular2/src/core/zone/vm_turn_zone'; +import {NgZone} from 'angular2/src/core/zone/ng_zone'; import {LifeCycle} from 'angular2/src/core/life_cycle/life_cycle'; import {ShadowDomStrategy} from 'angular2/src/render/dom/shadow_dom/shadow_dom_strategy'; import {EmulatedUnscopedShadowDomStrategy} from 'angular2/src/render/dom/shadow_dom/emulated_unscoped_shadow_dom_strategy'; @@ -77,10 +77,10 @@ function _injectorBindings(appComponentType): List { bind(appComponentType).toFactory((ref) => ref.instance, [appComponentRefToken]), bind(LifeCycle).toFactory((exceptionHandler) => new LifeCycle(exceptionHandler, null, assertionsEnabled()),[ExceptionHandler]), - bind(EventManager).toFactory((zone) => { + bind(EventManager).toFactory((ngZone) => { var plugins = [new HammerGesturesPlugin(), new KeyEventsPlugin(), new DomEventsPlugin()]; - return new EventManager(plugins, zone); - }, [VmTurnZone]), + return new EventManager(plugins, ngZone); + }, [NgZone]), bind(ShadowDomStrategy).toFactory( (styleUrlResolver, doc) => new EmulatedUnscopedShadowDomStrategy(styleUrlResolver, doc.head), [StyleUrlResolver, DOCUMENT_TOKEN]), @@ -123,7 +123,7 @@ function _injectorBindings(appComponentType): List { ]; } -function _createVmZone(givenReporter:Function): VmTurnZone { +function _createNgZone(givenReporter:Function): NgZone { var defaultErrorReporter = (exception, stackTrace) => { var longStackTrace = ListWrapper.join(stackTrace, "\n\n-----async gap-----\n"); DOM.logError(`${exception}\n\n${longStackTrace}`); @@ -132,7 +132,7 @@ function _createVmZone(givenReporter:Function): VmTurnZone { var reporter = isPresent(givenReporter) ? givenReporter : defaultErrorReporter; - var zone = new VmTurnZone({enableLongStackTrace: assertionsEnabled()}); + var zone = new NgZone({enableLongStackTrace: assertionsEnabled()}); zone.initCallbacks({onErrorHandler: reporter}); return zone; } @@ -247,7 +247,7 @@ export function bootstrap(appComponentType: Type, BrowserDomAdapter.makeCurrent(); var bootstrapProcess = PromiseWrapper.completer(); - var zone = _createVmZone(errorReporter); + var zone = _createNgZone(errorReporter); zone.run(() => { // TODO(rado): prepopulate template cache, so applications with only // index.html and main.js are possible. @@ -295,11 +295,11 @@ export class ApplicationRef { } } -function _createAppInjector(appComponentType: Type, bindings: List, zone: VmTurnZone): Injector { +function _createAppInjector(appComponentType: Type, bindings: List, zone: NgZone): Injector { if (isBlank(_rootInjector)) _rootInjector = Injector.resolveAndCreate(_rootBindings); var mergedBindings = isPresent(bindings) ? ListWrapper.concat(_injectorBindings(appComponentType), bindings) : _injectorBindings(appComponentType); - ListWrapper.push(mergedBindings, bind(VmTurnZone).toValue(zone)); + ListWrapper.push(mergedBindings, bind(NgZone).toValue(zone)); return _rootInjector.resolveAndCreateChild(mergedBindings); } diff --git a/modules/angular2/src/core/life_cycle/life_cycle.js b/modules/angular2/src/core/life_cycle/life_cycle.js index 982a1ea01d..940cbef79b 100644 --- a/modules/angular2/src/core/life_cycle/life_cycle.js +++ b/modules/angular2/src/core/life_cycle/life_cycle.js @@ -1,6 +1,6 @@ import {Injectable} from 'angular2/src/di/annotations_impl'; import {ChangeDetector} from 'angular2/change_detection'; -import {VmTurnZone} from 'angular2/src/core/zone/vm_turn_zone'; +import {NgZone} from 'angular2/src/core/zone/ng_zone'; import {ExceptionHandler} from 'angular2/src/core/exception_handler'; import {isPresent} from 'angular2/src/facade/lang'; @@ -46,7 +46,7 @@ export class LifeCycle { /** * @private */ - registerWith(zone:VmTurnZone, changeDetector:ChangeDetector = null) { + registerWith(zone:NgZone, changeDetector:ChangeDetector = null) { if (isPresent(changeDetector)) { this._changeDetector=changeDetector; } diff --git a/modules/angular2/src/core/zone/vm_turn_zone.cjs b/modules/angular2/src/core/zone/ng_zone.cjs similarity index 92% rename from modules/angular2/src/core/zone/vm_turn_zone.cjs rename to modules/angular2/src/core/zone/ng_zone.cjs index dd6aec399b..12173d7986 100644 --- a/modules/angular2/src/core/zone/vm_turn_zone.cjs +++ b/modules/angular2/src/core/zone/ng_zone.cjs @@ -1,6 +1,6 @@ // TODO(vicb): implement this class properly // The current stub implementation is only here to please cjs tests -export class VmTurnZone { +export class NgZone { constructor({enableLongStackTrace}) { } diff --git a/modules/angular2/src/core/zone/vm_turn_zone.dart b/modules/angular2/src/core/zone/ng_zone.dart similarity index 87% rename from modules/angular2/src/core/zone/vm_turn_zone.dart rename to modules/angular2/src/core/zone/ng_zone.dart index a4d4f58695..b1b8eb4500 100644 --- a/modules/angular2/src/core/zone/vm_turn_zone.dart +++ b/modules/angular2/src/core/zone/ng_zone.dart @@ -12,20 +12,20 @@ import 'package:stack_trace/stack_trace.dart' show Chain; * * A VM turn consist of a single macrotask followed 0 to many microtasks. * - * The wrapper maintains an "inner" and "outer" `Zone`. The application code will executes + * The wrapper maintains an "inner" and "mount" `Zone`. The application code will executes * in the "inner" zone unless `runOutsideAngular` is explicitely called. * - * A typical application will create a singleton `VmTurnZone`. The outer `Zone` is a fork of the root - * `Zone`. The default `onTurnDone` runs the Angular change detection. + * A typical application will create a singleton `NgZone`. The mount zone is the `Zone` where the singleton has been + * instantiated. The default `onTurnDone` runs the Angular change detection. */ -class VmTurnZone { +class NgZone { Function _onTurnStart; Function _onTurnDone; Function _onErrorHandler; - // Code executed in _outerZone does not trigger the onTurnDone. - Zone _outerZone; - // _innerZone is the child of _outerZone. Any code executed in this zone will trigger the + // Code executed in _mountZone does not trigger the onTurnDone. + Zone _mountZone; + // _innerZone is the child of _mountZone. Any code executed in this zone will trigger the // onTurnDone hook at the end of the current VM turn. Zone _innerZone; @@ -42,14 +42,14 @@ class VmTurnZone { /** * Associates with this * - * - an "outer" [Zone], which is a the one that created this. - * - an "inner" [Zone], which is a child of the outer [Zone]. + * - a "mount" [Zone], which is a the one that instantiated this. + * - an "inner" [Zone], which is a child of the mount [Zone]. * * @param {bool} enableLongStackTrace whether to enable long stack trace. They should only be * enabled in development mode as they significantly impact perf. */ - VmTurnZone({bool enableLongStackTrace}) { - _outerZone = Zone.current; + NgZone({bool enableLongStackTrace}) { + _mountZone = Zone.current; if (enableLongStackTrace) { _innerZone = Chain.capture( @@ -68,7 +68,7 @@ class VmTurnZone { * Initializes the zone hooks. * * The given error handler should re-throw the passed exception. Otherwise, exceptions will not - * propagate outside of the [VmTurnZone] and can alter the application execution flow. + * propagate outside of the [NgZone] and can alter the application execution flow. * Not re-throwing could be used to help testing the code or advanced use cases. * * @param {Function} onTurnStart called before code executes in the inner zone for each VM turn @@ -88,7 +88,7 @@ class VmTurnZone { * Angular's auto digest mechanism. * * ``` - * VmTurnZone zone = ; + * NgZone zone = ; * * void functionCalledFromJS() { * zone.run(() { @@ -105,13 +105,13 @@ class VmTurnZone { } /** - * Runs `fn` in the outer zone and returns whatever it returns. + * Runs `fn` in the mount zone and returns whatever it returns. * * In a typical app where the inner zone is the Angular zone, this allows one to escape Angular's * auto-digest mechanism. * * ``` - * void myFunction(VmTurnZone zone, Element element) { + * void myFunction(NgZone zone, Element element) { * element.onClick.listen(() { * // auto-digest will run after element click. * }); @@ -124,7 +124,7 @@ class VmTurnZone { * ``` */ dynamic runOutsideAngular(fn()) { - return _outerZone.run(fn); + return _mountZone.run(fn); } void _maybeStartVmTurn(ZoneDelegate parent) { diff --git a/modules/angular2/src/core/zone/vm_turn_zone.es6 b/modules/angular2/src/core/zone/ng_zone.es6 similarity index 72% rename from modules/angular2/src/core/zone/vm_turn_zone.es6 rename to modules/angular2/src/core/zone/ng_zone.es6 index 5f09271870..5cb1bac219 100644 --- a/modules/angular2/src/core/zone/vm_turn_zone.es6 +++ b/modules/angular2/src/core/zone/ng_zone.es6 @@ -4,18 +4,18 @@ import {normalizeBlank, isPresent, global} from 'angular2/src/facade/lang'; /** * A wrapper around zones that lets you schedule tasks after it has executed a task. * - * The wrapper maintains an "inner" and "outer" `Zone`. The application code will executes + * The wrapper maintains an "inner" and an "mount" `Zone`. The application code will executes * in the "inner" zone unless `runOutsideAngular` is explicitely called. * - * A typical application will create a singleton `VmTurnZone`. The outer `Zone` is a fork of the root + * A typical application will create a singleton `NgZone`. The outer `Zone` is a fork of the root * `Zone`. The default `onTurnDone` runs the Angular change detection. * * @exportedAs angular2/core */ -export class VmTurnZone { - // Code executed in _outerZone does not trigger the onTurnDone. - _outerZone; - // _innerZone is the child of _outerZone. Any code executed in this zone will trigger the +export class NgZone { + // Code executed in _mountZone does not trigger the onTurnDone. + _mountZone; + // _innerZone is the child of _mountZone. Any code executed in this zone will trigger the // onTurnDone hook at the end of the current VM turn. _innerZone; @@ -23,11 +23,11 @@ export class VmTurnZone { _onTurnDone:Function; _onErrorHandler:Function; - // Number of microtasks pending from _outerZone (& descendants) + // Number of microtasks pending from _innerZone (& descendants) _pendingMicrotask: number; // Whether some code has been executed in the _innerZone (& descendants) in the current turn _hasExecutedCodeInInnerZone: boolean; - // run() call depth in _outerZone. 0 at the end of a macrotask + // run() call depth in _mountZone. 0 at the end of a macrotask // zone.run(() => { // top-level call // zone.run(() => {}); // nested call -> in-turn // }); @@ -36,8 +36,8 @@ export class VmTurnZone { /** * Associates with this * - * - an "outer" zone, which is a child of the one that created this. - * - an "inner" zone, which is a child of the outer zone. + * - a "root" zone, which the one that instantiated this. + * - an "inner" zone, which is a child of the root zone. * * @param {bool} enableLongStackTrace whether to enable long stack trace. They should only be * enabled in development mode as they significantly impact perf. @@ -51,8 +51,8 @@ export class VmTurnZone { this._hasExecutedCodeInInnerZone = false; this._nestedRun = 0; - this._outerZone = global.zone; - this._innerZone = this._createInnerZone(this._outerZone, enableLongStackTrace) + this._mountZone = global.zone; + this._innerZone = this._createInnerZone(this._mountZone, enableLongStackTrace) } /** @@ -75,7 +75,7 @@ export class VmTurnZone { * Angular's auto digest mechanism. * * ``` - * var zone: VmTurnZone = [ref to the application zone]; + * var zone: NgZone = [ref to the application zone]; * * zone.run(() => { * // the change detection will run after this function and the microtasks it enqueues have executed. @@ -93,7 +93,7 @@ export class VmTurnZone { * auto-digest mechanism. * * ``` - * var zone: VmTurnZone = [ref to the application zone]; + * var zone: NgZone = [ref to the application zone]; * * zone.runOusideAngular(() => { * element.onClick(() => { @@ -103,23 +103,23 @@ export class VmTurnZone { * ``` */ runOutsideAngular(fn) { - return this._outerZone.run(fn); + return this._mountZone.run(fn); } _createInnerZone(zone, enableLongStackTrace) { - var vmTurnZone = this; + var ngZone = this; var errorHandling; if (enableLongStackTrace) { errorHandling = StringMapWrapper.merge(Zone.longStackTraceZone, { onError: function (e) { - vmTurnZone._onError(this, e) + ngZone._onError(this, e) } }); } else { errorHandling = { onError: function (e) { - vmTurnZone._onError(this, e) + ngZone._onError(this, e) } }; } @@ -130,25 +130,25 @@ export class VmTurnZone { '$run': function(parentRun) { return function() { try { - vmTurnZone._nestedRun++; - if (!vmTurnZone._hasExecutedCodeInInnerZone) { - vmTurnZone._hasExecutedCodeInInnerZone = true; - if (vmTurnZone._onTurnStart) { - parentRun.call(vmTurnZone._innerZone, vmTurnZone._onTurnStart); + ngZone._nestedRun++; + if (!ngZone._hasExecutedCodeInInnerZone) { + ngZone._hasExecutedCodeInInnerZone = true; + if (ngZone._onTurnStart) { + parentRun.call(ngZone._innerZone, ngZone._onTurnStart); } } return parentRun.apply(this, arguments); } finally { - vmTurnZone._nestedRun--; + ngZone._nestedRun--; // If there are no more pending microtasks, we are at the end of a VM turn (or in onTurnStart) // _nestedRun will be 0 at the end of a macrotasks (it could be > 0 when there are nested calls // to run()). - if (vmTurnZone._pendingMicrotasks == 0 && vmTurnZone._nestedRun == 0) { - if (vmTurnZone._onTurnDone && vmTurnZone._hasExecutedCodeInInnerZone) { + if (ngZone._pendingMicrotasks == 0 && ngZone._nestedRun == 0) { + if (ngZone._onTurnDone && ngZone._hasExecutedCodeInInnerZone) { try { - parentRun.call(vmTurnZone._innerZone, vmTurnZone._onTurnDone); + parentRun.call(ngZone._innerZone, ngZone._onTurnDone); } finally { - vmTurnZone._hasExecutedCodeInInnerZone = false; + ngZone._hasExecutedCodeInInnerZone = false; } } } @@ -157,12 +157,12 @@ export class VmTurnZone { }, '$scheduleMicrotask': function(parentScheduleMicrotask) { return function(fn) { - vmTurnZone._pendingMicrotasks++; + ngZone._pendingMicrotasks++; var microtask = function() { try { fn(); } finally { - vmTurnZone._pendingMicrotasks--; + ngZone._pendingMicrotasks--; } }; parentScheduleMicrotask.call(this, microtask); diff --git a/modules/angular2/src/mock/vm_turn_zone_mock.js b/modules/angular2/src/mock/ng_zone_mock.js similarity index 51% rename from modules/angular2/src/mock/vm_turn_zone_mock.js rename to modules/angular2/src/mock/ng_zone_mock.js index 1aa08f64c2..b0b1660d35 100644 --- a/modules/angular2/src/mock/vm_turn_zone_mock.js +++ b/modules/angular2/src/mock/ng_zone_mock.js @@ -1,12 +1,12 @@ -import {VmTurnZone} from 'angular2/src/core/zone/vm_turn_zone'; +import {NgZone} from 'angular2/src/core/zone/ng_zone'; -export class MockVmTurnZone extends VmTurnZone { +export class MockNgZone extends NgZone { constructor() { super({enableLongStackTrace: false}); } run(fn) { - fn(); + return fn(); } runOutsideAngular(fn) { diff --git a/modules/angular2/src/render/dom/events/event_manager.js b/modules/angular2/src/render/dom/events/event_manager.js index 424c3e3728..b6fb6782a8 100644 --- a/modules/angular2/src/render/dom/events/event_manager.js +++ b/modules/angular2/src/render/dom/events/event_manager.js @@ -1,15 +1,15 @@ import {isBlank, BaseException, isPresent, StringWrapper} from 'angular2/src/facade/lang'; import {DOM} from 'angular2/src/dom/dom_adapter'; import {List, ListWrapper, MapWrapper} from 'angular2/src/facade/collection'; -import {VmTurnZone} from 'angular2/src/core/zone/vm_turn_zone'; +import {NgZone} from 'angular2/src/core/zone/ng_zone'; var BUBBLE_SYMBOL = '^'; export class EventManager { _plugins: List; - _zone: VmTurnZone; + _zone: NgZone; - constructor(plugins: List, zone: VmTurnZone) { + constructor(plugins: List, zone: NgZone) { this._zone = zone; this._plugins = plugins; for (var i = 0; i < plugins.length; i++) { @@ -29,7 +29,7 @@ export class EventManager { return plugin.addGlobalEventListener(target, withoutBubbleSymbol, handler, withoutBubbleSymbol != eventName); } - getZone(): VmTurnZone { + getZone(): NgZone { return this._zone; } @@ -93,7 +93,7 @@ export class DomEventsPlugin extends EventManagerPlugin { }); } - _getOutsideHandler(shouldSupportBubble: boolean, element, handler: Function, zone: VmTurnZone) { + _getOutsideHandler(shouldSupportBubble: boolean, element, handler: Function, zone: NgZone) { return shouldSupportBubble ? DomEventsPlugin.bubbleCallback(element, handler, zone) : DomEventsPlugin.sameElementCallback(element, handler, zone); diff --git a/modules/angular2/src/test_lib/test_injector.js b/modules/angular2/src/test_lib/test_injector.js index bd9f584424..6cdc4aec62 100644 --- a/modules/angular2/src/test_lib/test_injector.js +++ b/modules/angular2/src/test_lib/test_injector.js @@ -16,7 +16,7 @@ import {ComponentUrlMapper} from 'angular2/src/core/compiler/component_url_mappe import {UrlResolver} from 'angular2/src/services/url_resolver'; import {StyleUrlResolver} from 'angular2/src/render/dom/shadow_dom/style_url_resolver'; import {StyleInliner} from 'angular2/src/render/dom/shadow_dom/style_inliner'; -import {VmTurnZone} from 'angular2/src/core/zone/vm_turn_zone'; +import {NgZone} from 'angular2/src/core/zone/ng_zone'; import {DOM} from 'angular2/src/dom/dom_adapter'; @@ -24,7 +24,7 @@ import {EventManager, DomEventsPlugin} from 'angular2/src/render/dom/events/even import {MockTemplateResolver} from 'angular2/src/mock/template_resolver_mock'; import {MockXHR} from 'angular2/src/mock/xhr_mock'; -import {MockVmTurnZone} from 'angular2/src/mock/vm_turn_zone_mock'; +import {MockNgZone} from 'angular2/src/mock/ng_zone_mock'; import {TestBed} from './test_bed'; @@ -102,13 +102,13 @@ function _getAppBindings() { StyleUrlResolver, StyleInliner, TestBed, - bind(VmTurnZone).toClass(MockVmTurnZone), + bind(NgZone).toClass(MockNgZone), bind(EventManager).toFactory((zone) => { var plugins = [ new DomEventsPlugin(), ]; return new EventManager(plugins, zone); - }, [VmTurnZone]), + }, [NgZone]), ]; } diff --git a/modules/angular2/test/core/zone/vm_turn_zone_spec.js b/modules/angular2/test/core/zone/ng_zone_spec.js similarity index 98% rename from modules/angular2/test/core/zone/vm_turn_zone_spec.js rename to modules/angular2/test/core/zone/ng_zone_spec.js index 4b34f3a094..0ee967a661 100644 --- a/modules/angular2/test/core/zone/vm_turn_zone_spec.js +++ b/modules/angular2/test/core/zone/ng_zone_spec.js @@ -17,7 +17,7 @@ import {PromiseWrapper} from 'angular2/src/facade/async'; import {ListWrapper} from 'angular2/src/facade/collection'; import {BaseException} from 'angular2/src/facade/lang'; -import {VmTurnZone} from 'angular2/src/core/zone/vm_turn_zone'; +import {NgZone} from 'angular2/src/core/zone/ng_zone'; // Schedules a macrotask (using a timer) function macroTask(fn: Function): void { @@ -40,10 +40,10 @@ function logError(error, stackTrace) { } export function main() { - describe("VmTurnZone", () => { + describe("NgZone", () => { function createZone(enableLongStackTrace) { - var zone = new VmTurnZone({enableLongStackTrace: enableLongStackTrace}); + var zone = new NgZone({enableLongStackTrace: enableLongStackTrace}); zone.initCallbacks({ onTurnStart: _log.fn('onTurnStart'), onTurnDone: _log.fn('onTurnDone') diff --git a/modules/angular2/test/render/dom/events/event_manager_spec.js b/modules/angular2/test/render/dom/events/event_manager_spec.js index 3d335d7cc5..10663ace68 100644 --- a/modules/angular2/test/render/dom/events/event_manager_spec.js +++ b/modules/angular2/test/render/dom/events/event_manager_spec.js @@ -1,6 +1,6 @@ import {describe, ddescribe, it, iit, xit, xdescribe, expect, beforeEach, el} from 'angular2/test_lib'; import {EventManager, EventManagerPlugin, DomEventsPlugin} from 'angular2/src/render/dom/events/event_manager'; -import {VmTurnZone} from 'angular2/src/core/zone/vm_turn_zone'; +import {NgZone} from 'angular2/src/core/zone/ng_zone'; import {List, ListWrapper, Map, MapWrapper} from 'angular2/src/facade/collection'; import {DOM} from 'angular2/src/dom/dom_adapter'; @@ -17,7 +17,7 @@ export function main() { var element = el('
'); var handler = (e) => e; var plugin = new FakeEventManagerPlugin(['click']); - var manager = new EventManager([plugin, domEventPlugin], new FakeVmTurnZone()); + var manager = new EventManager([plugin, domEventPlugin], new FakeNgZone()); manager.addEventListener(element, 'click', handler); expect(MapWrapper.get(plugin._nonBubbleEventHandlers, 'click')).toBe(handler); }); @@ -26,7 +26,7 @@ export function main() { var element = el('
'); var handler = (e) => e; var plugin = new FakeEventManagerPlugin(['click']); - var manager = new EventManager([plugin, domEventPlugin], new FakeVmTurnZone()); + var manager = new EventManager([plugin, domEventPlugin], new FakeNgZone()); manager.addEventListener(element, '^click', handler); expect(MapWrapper.get(plugin._bubbleEventHandlers, 'click')).toBe(handler); }); @@ -37,7 +37,7 @@ export function main() { var dblClickHandler = (e) => e; var plugin1= new FakeEventManagerPlugin(['dblclick']); var plugin2 = new FakeEventManagerPlugin(['click', 'dblclick']); - var manager = new EventManager([plugin1, plugin2], new FakeVmTurnZone()); + var manager = new EventManager([plugin1, plugin2], new FakeNgZone()); manager.addEventListener(element, 'click', clickHandler); manager.addEventListener(element, 'dblclick', dblClickHandler); expect(MapWrapper.contains(plugin1._nonBubbleEventHandlers, 'click')).toBe(false); @@ -49,7 +49,7 @@ export function main() { it('should throw when no plugin can handle the event', () => { var element = el('
'); var plugin = new FakeEventManagerPlugin(['dblclick']); - var manager = new EventManager([plugin], new FakeVmTurnZone()); + var manager = new EventManager([plugin], new FakeNgZone()); expect(() => manager.addEventListener(element, 'click', null)) .toThrowError('No event manager plugin found for event click'); }); @@ -60,7 +60,7 @@ export function main() { var dispatchedEvent = DOM.createMouseEvent('click'); var receivedEvent = null; var handler = (e) => { receivedEvent = e; }; - var manager = new EventManager([domEventPlugin], new FakeVmTurnZone()); + var manager = new EventManager([domEventPlugin], new FakeNgZone()); manager.addEventListener(element, 'click', handler); DOM.dispatchEvent(child, dispatchedEvent); @@ -76,7 +76,7 @@ export function main() { var dispatchedEvent = DOM.createMouseEvent('click'); var receivedEvent = null; var handler = (e) => { receivedEvent = e; }; - var manager = new EventManager([domEventPlugin], new FakeVmTurnZone()); + var manager = new EventManager([domEventPlugin], new FakeNgZone()); manager.addEventListener(element, '^click', handler); DOM.dispatchEvent(child, dispatchedEvent); @@ -89,7 +89,7 @@ export function main() { var dispatchedEvent = DOM.createMouseEvent('click'); var receivedEvent = null; var handler = (e) => { receivedEvent = e; }; - var manager = new EventManager([domEventPlugin], new FakeVmTurnZone()); + var manager = new EventManager([domEventPlugin], new FakeNgZone()); var remover = manager.addGlobalEventListener("document", '^click', handler); DOM.dispatchEvent(element, dispatchedEvent); @@ -130,7 +130,7 @@ class FakeEventManagerPlugin extends EventManagerPlugin { } } -class FakeVmTurnZone extends VmTurnZone { +class FakeNgZone extends NgZone { constructor() { super({enableLongStackTrace: false}); } diff --git a/tools/broccoli/trees/node_tree.ts b/tools/broccoli/trees/node_tree.ts index 28ca14c644..0f5bfd9b42 100644 --- a/tools/broccoli/trees/node_tree.ts +++ b/tools/broccoli/trees/node_tree.ts @@ -22,7 +22,7 @@ module.exports = function makeNodeTree(destinationPath) { include: ['angular2/**', 'benchpress/**', 'rtts_assert/**', '**/e2e_test/**'], exclude: [ // the following code and tests are not compatible with CJS/node environment - 'angular2/src/core/zone/vm_turn_zone.es6', + 'angular2/src/core/zone/ng_zone.es6', 'angular2/test/core/zone/**' ] });