-
Notifications
You must be signed in to change notification settings - Fork 27.2k
fix: make sure that Zone does not show up in angular2.d.ts #7655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,13 +8,12 @@ export class NgZoneError { | |
| } | ||
|
|
||
|
|
||
| export class NgZoneImpl implements ZoneSpec { | ||
| export class NgZoneImpl { | ||
| static isInAngularZone(): boolean { return Zone.current.get('isAngularZone') === true; } | ||
|
|
||
| public name: string = 'angular'; | ||
| public properties: {[k: string]: string} = <any>{'isAngularZone': true}; | ||
|
|
||
| /** @internal */ | ||
| private outer: Zone; | ||
| /** @internal */ | ||
| private inner: Zone; | ||
|
|
||
| private onEnter: () => void; | ||
|
|
@@ -37,60 +36,64 @@ export class NgZoneImpl implements ZoneSpec { | |
| this.setMacrotask = setMacrotask; | ||
| this.onError = onError; | ||
|
|
||
| if (global.Zone) { | ||
| if (Zone) { | ||
| this.outer = this.inner = Zone.current; | ||
| if (Zone['wtfZoneSpec']) { | ||
| this.inner = this.inner.fork(Zone['wtfZoneSpec']); | ||
| } | ||
| if (trace) { | ||
| this.inner = this.inner.fork(Zone['longStackTraceZoneSpec']); | ||
| } | ||
| this.inner = this.inner.fork(this); | ||
| } else { | ||
| throw new Error('Angular2 needs to be run with Zone.js polyfill.'); | ||
| } | ||
| } | ||
| this.inner = this.inner.fork({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this gets pretty deeply nested, did you consider a private inner class that implements ZoneSpec?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I thought about it, but this is cheaper in terms of number of bytes. If you feel strongly I can make the change.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, don't feel strongly. On Thu, Mar 17, 2016 at 9:56 PM Miško Hevery notifications@github.com
|
||
| name: 'angular', | ||
| properties:<any>{'isAngularZone': true}, | ||
| onInvokeTask: (delegate: ZoneDelegate, current: Zone, target: Zone, task: Task, | ||
| applyThis: any, applyArgs: any): any => { | ||
| try { | ||
| this.onEnter(); | ||
| return delegate.invokeTask(target, task, applyThis, applyArgs); | ||
| } finally { | ||
| this.onLeave(); | ||
| } | ||
| }, | ||
|
|
||
| onInvokeTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task, applyThis: any, | ||
| applyArgs: any): any { | ||
| try { | ||
| this.onEnter(); | ||
| return delegate.invokeTask(target, task, applyThis, applyArgs); | ||
| } finally { | ||
| this.onLeave(); | ||
| } | ||
| }; | ||
|
|
||
| onInvoke: (delegate: ZoneDelegate, current: Zone, target: Zone, callback: Function, | ||
| applyThis: any, applyArgs: any[], source: string): any => { | ||
| try { | ||
| this.onEnter(); | ||
| return delegate.invoke(target, callback, applyThis, applyArgs, source); | ||
| } finally { | ||
| this.onLeave(); | ||
| } | ||
| }, | ||
|
|
||
| onInvoke(delegate: ZoneDelegate, current: Zone, target: Zone, callback: Function, applyThis: any, | ||
| applyArgs: any[], source: string): any { | ||
| try { | ||
| this.onEnter(); | ||
| return delegate.invoke(target, callback, applyThis, applyArgs, source); | ||
| } finally { | ||
| this.onLeave(); | ||
| } | ||
| } | ||
| onHasTask: | ||
| (delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState) => { | ||
| delegate.hasTask(target, hasTaskState); | ||
| if (current == target) { | ||
| // We are only interested in hasTask events which originate from our zone | ||
| // (A child hasTask event is not interesting to us) | ||
| if (hasTaskState.change == 'microTask') { | ||
| this.setMicrotask(hasTaskState.microTask); | ||
| } else if (hasTaskState.change == 'macroTask') { | ||
| this.setMacrotask(hasTaskState.macroTask); | ||
| } | ||
| } | ||
| }, | ||
|
|
||
| onHasTask(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState) { | ||
| delegate.hasTask(target, hasTaskState); | ||
| if (current == target) { | ||
| // We are only interested in hasTask events which originate from our zone | ||
| // (A child hasTask event is not interesting to us) | ||
| if (hasTaskState.change == 'microTask') { | ||
| this.setMicrotask(hasTaskState.microTask); | ||
| } else if (hasTaskState.change == 'macroTask') { | ||
| this.setMacrotask(hasTaskState.macroTask); | ||
| } | ||
| onHandleError: (delegate: ZoneDelegate, current: Zone, target: Zone, error: any): | ||
| boolean => { | ||
| delegate.handleError(target, error); | ||
| this.onError(new NgZoneError(error, error.stack)); | ||
| return false; | ||
| } | ||
| }); | ||
| } else { | ||
| throw new Error('Angular2 needs to be run with Zone.js polyfill.'); | ||
| } | ||
| } | ||
|
|
||
| onHandleError(delegate: ZoneDelegate, current: Zone, target: Zone, error: any): boolean { | ||
| delegate.handleError(target, error); | ||
| this.onError(new NgZoneError(error, error.stack)); | ||
| return false; | ||
| } | ||
|
|
||
| runInner(fn: () => any): any { return this.inner.runGuarded(fn); }; | ||
| runOuter(fn: () => any): any { return this.outer.run(fn); }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ import { | |
| import {Message, id} from 'angular2/src/i18n/message'; | ||
|
|
||
| export function main() { | ||
| ddescribe('Message', () => { | ||
| describe('Message', () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this have anything to do with us missing the bad release? or are we still missing test coverage?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a separate SHA. We were only running single test on Travis. |
||
| describe("id", () => { | ||
| it("should return a different id for messages with and without the meaning", () => { | ||
| let m1 = new Message("content", "meaning", null); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, this is why the test was passing.