Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
fix(format): update clang-format to 1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaLiPassion authored and mhevery committed Jun 18, 2018
1 parent 915042d commit f238908
Show file tree
Hide file tree
Showing 52 changed files with 1,359 additions and 1,350 deletions.
4 changes: 2 additions & 2 deletions lib/browser/define-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ function _tryDefineProperty(obj: any, prop: string, desc: any, originalConfigura
} catch (error) {
descJson = desc.toString();
}
console.log(`Attempting to configure '${prop}' with descriptor '${descJson
}' on object '${obj}' and got error, giving up: ${error}`);
console.log(`Attempting to configure '${prop}' with descriptor '${descJson}' on object '${
obj}' and got error, giving up: ${error}`);
}
} else {
throw error;
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/webapis-media-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Zone.__load_patch('mediaQuery', (global: any, Zone: ZoneType, api: _ZonePrivate)
patchAddListener(mql);
patchRemoveListener(mql);
} else if (mql['addListener']) {
// proto not exists, or proto has no addListener method
// proto not exists, or proto has no addListener method
// try to patch mql instance
patchAddListener(mql);
patchRemoveListener(mql);
Expand Down
79 changes: 42 additions & 37 deletions lib/browser/webapis-resize-observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,44 +45,49 @@ Zone.__load_patch('ResizeObserver', (global: any, Zone: any, api: _ZonePrivate)
return args.length > 0 ? new ResizeObserver(args[0]) : new ResizeObserver();
});

api.patchMethod(ResizeObserver.prototype, 'observe', (delegate: Function) => (self: any, args: any[]) => {
const target = args.length > 0 ? args[0] : null;
if (!target) {
return delegate.apply(self, args);
}
let targets = self[resizeObserverSymbol];
if (!targets) {
targets = self[resizeObserverSymbol] = [];
}
targets.push(target);
target[resizeObserverSymbol] = Zone.current;
return delegate.apply(self, args);
});
api.patchMethod(
ResizeObserver.prototype, 'observe', (delegate: Function) => (self: any, args: any[]) => {
const target = args.length > 0 ? args[0] : null;
if (!target) {
return delegate.apply(self, args);
}
let targets = self[resizeObserverSymbol];
if (!targets) {
targets = self[resizeObserverSymbol] = [];
}
targets.push(target);
target[resizeObserverSymbol] = Zone.current;
return delegate.apply(self, args);
});

api.patchMethod(ResizeObserver.prototype, 'unobserve', (delegate: Function) => (self: any, args: any[]) => {
const target = args.length > 0 ? args[0] : null;
if (!target) {
return delegate.apply(self, args);
}
let targets = self[resizeObserverSymbol];
if (targets) {
for (let i = 0; i < targets.length; i ++) {
if (targets[i] === target) {
targets.splice(i, 1);
break;
api.patchMethod(
ResizeObserver.prototype, 'unobserve', (delegate: Function) => (self: any, args: any[]) => {
const target = args.length > 0 ? args[0] : null;
if (!target) {
return delegate.apply(self, args);
}
}
}
target[resizeObserverSymbol] = undefined;
return delegate.apply(self, args);
});
let targets = self[resizeObserverSymbol];
if (targets) {
for (let i = 0; i < targets.length; i++) {
if (targets[i] === target) {
targets.splice(i, 1);
break;
}
}
}
target[resizeObserverSymbol] = undefined;
return delegate.apply(self, args);
});

api.patchMethod(ResizeObserver.prototype, 'disconnect', (delegate: Function) => (self: any, args: any[]) => {
const targets = self[resizeObserverSymbol];
if (targets) {
targets.forEach((target: any) => {target[resizeObserverSymbol] = undefined;});
self[resizeObserverSymbol] = undefined;
}
return delegate.apply(self, args);
});
api.patchMethod(
ResizeObserver.prototype, 'disconnect', (delegate: Function) => (self: any, args: any[]) => {
const targets = self[resizeObserverSymbol];
if (targets) {
targets.forEach((target: any) => {
target[resizeObserverSymbol] = undefined;
});
self[resizeObserverSymbol] = undefined;
}
return delegate.apply(self, args);
});
});
1 change: 0 additions & 1 deletion lib/common/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ export function patchEventTarget(
const typeOfDelegate = typeof delegate;
return (typeOfDelegate === 'function' && task.callback === delegate) ||
(typeOfDelegate === 'object' && task.originalDelegate === delegate);

};

const compare =
Expand Down
10 changes: 5 additions & 5 deletions lib/common/promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr
if (rejection) {
console.error(
'Unhandled Promise rejection:',
rejection instanceof Error ? rejection.message : rejection, '; Zone:',
(<Zone>e.zone).name, '; Task:', e.task && (<Task>e.task).source, '; Value:', rejection,
rejection instanceof Error ? rejection.stack : undefined);
rejection instanceof Error ? rejection.message : rejection,
'; Zone:', (<Zone>e.zone).name, '; Task:', e.task && (<Task>e.task).source,
'; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined);
} else {
console.error(e);
}
Expand Down Expand Up @@ -239,8 +239,8 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr

function scheduleResolveOrReject<R, U1, U2>(
promise: ZoneAwarePromise<any>, zone: AmbientZone, chainPromise: ZoneAwarePromise<any>,
onFulfilled?: ((value: R) => U1) | null | undefined,
onRejected?: ((error: any) => U2) | null | undefined): void {
onFulfilled?: ((value: R) => U1)|null|undefined,
onRejected?: ((error: any) => U2)|null|undefined): void {
clearRejectedNoCatch(promise);
const promiseState = (promise as any)[symbolState];
const delegate = promiseState ?
Expand Down
33 changes: 17 additions & 16 deletions lib/extra/bluebird.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@ Zone.__load_patch('bluebird', (global: any, Zone: ZoneType, api: _ZonePrivate) =
// patch method of Bluebird.prototype which not using `then` internally
const bluebirdApis: string[] = ['then', 'spread', 'finally'];
bluebirdApis.forEach(bapi => {
api.patchMethod(Bluebird.prototype, bapi, (delegate: Function) => (self: any, args: any[]) => {
const zone = Zone.current;
for (let i = 0; i < args.length; i ++) {
const func = args[i];
if (typeof func === 'function') {
args[i] = function() {
const argSelf: any = this;
const argArgs: any = arguments;
zone.scheduleMicroTask('Promise.then', () => {
return func.apply(argSelf, argArgs);
});
};
}
}
return delegate.apply(self, args);
});
api.patchMethod(
Bluebird.prototype, bapi, (delegate: Function) => (self: any, args: any[]) => {
const zone = Zone.current;
for (let i = 0; i < args.length; i++) {
const func = args[i];
if (typeof func === 'function') {
args[i] = function() {
const argSelf: any = this;
const argArgs: any = arguments;
zone.scheduleMicroTask('Promise.then', () => {
return func.apply(argSelf, argArgs);
});
};
}
}
return delegate.apply(self, args);
});
});

// override global promise
Expand Down
12 changes: 7 additions & 5 deletions lib/extra/jsonp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ Zone.__load_patch('jsonp', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
}
});

api.patchMethod(options.jsonp, options.sendFuncName, (delegate: Function) => (self: any, args: any[]) => {
global[api.symbol('jsonpTask')] = Zone.current.scheduleMacroTask('jsonp', noop, {}, (task: Task) => {
return delegate.apply(self, args);
}, noop);
});
api.patchMethod(
options.jsonp, options.sendFuncName, (delegate: Function) => (self: any, args: any[]) => {
global[api.symbol('jsonpTask')] =
Zone.current.scheduleMacroTask('jsonp', noop, {}, (task: Task) => {
return delegate.apply(self, args);
}, noop);
});
};
});
3 changes: 2 additions & 1 deletion lib/jasmine/jasmine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@
(jasmine as any).QueueRunner = (function(_super) {
__extends(ZoneQueueRunner, _super);
function ZoneQueueRunner(attrs: {
onComplete: Function; userContext?: any;
onComplete: Function;
userContext?: any;
timeout?: {setTimeout: Function; clearTimeout: Function};
onException?: (error: any) => void;
}) {
Expand Down
5 changes: 1 addition & 4 deletions lib/mocha/mocha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
testZone = rootZone.fork(new ProxyZoneSpec());
});

this.on('fail', (test:any, err: any) => {
this.on('fail', (test: any, err: any) => {
const proxyZoneSpec = testZone && testZone.get('ProxyZoneSpec');
if (proxyZoneSpec && err) {
err.message += proxyZoneSpec.getAndClearPendingTasksInfo();
Expand All @@ -170,8 +170,5 @@

return originalRun.call(this, fn);
};


})(Mocha.Runner.prototype.runTest, Mocha.Runner.prototype.run);

})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);
1 change: 0 additions & 1 deletion lib/node/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ Zone.__load_patch(
});
};
}

});


Expand Down
2 changes: 1 addition & 1 deletion lib/rxjs/rxjs-fake-async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

import {Scheduler} from 'rxjs/Scheduler';
import {async} from 'rxjs/scheduler/async';
import {asap} from 'rxjs/scheduler/asap';
import {async} from 'rxjs/scheduler/async';

Zone.__load_patch('rxjs.Scheduler.now', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
api.patchMethod(Scheduler, 'now', (delegate: Function) => (self: any, args: any[]) => {
Expand Down
6 changes: 4 additions & 2 deletions lib/rxjs/rxjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber';
const empty = {
closed: true,
next(value: any): void{},
error(err: any): void{throw err;},
complete(): void{}
error(err: any): void {
throw err;
},
complete(): void {}
};

function toSubscriber<T>(
Expand Down
34 changes: 17 additions & 17 deletions lib/testing/fake-async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ Zone.__load_patch('fakeasync', (global: any, Zone: ZoneType, api: _ZonePrivate)
}

/**
* Wraps a function to be executed in the fakeAsync zone:
* - microtasks are manually executed by calling `flushMicrotasks()`,
* - timers are synchronous, `tick()` simulates the asynchronous passage of time.
*
* If there are any pending timers at the end of the function, an exception will be thrown.
*
* Can be used to wrap inject() calls.
*
* ## Example
*
* {@example core/testing/ts/fake_async.ts region='basic'}
*
* @param fn
* @returns The function wrapped to be executed in the fakeAsync zone
*
* @experimental
*/
* Wraps a function to be executed in the fakeAsync zone:
* - microtasks are manually executed by calling `flushMicrotasks()`,
* - timers are synchronous, `tick()` simulates the asynchronous passage of time.
*
* If there are any pending timers at the end of the function, an exception will be thrown.
*
* Can be used to wrap inject() calls.
*
* ## Example
*
* {@example core/testing/ts/fake_async.ts region='basic'}
*
* @param fn
* @returns The function wrapped to be executed in the fakeAsync zone
*
* @experimental
*/
function fakeAsync(fn: Function): (...args: any[]) => any {
// Not using an arrow function to preserve context passed from call site
return function(...args: any[]) {
Expand Down
46 changes: 23 additions & 23 deletions lib/testing/promise-testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@
* found in the LICENSE file at https://angular.io/license
*/

/**
* Promise for async/fakeAsync zoneSpec test
* can support async operation which not supported by zone.js
* such as
* it ('test jsonp in AsyncZone', async() => {
* new Promise(res => {
* jsonp(url, (data) => {
* // success callback
* res(data);
* });
* }).then((jsonpResult) => {
* // get jsonp result.
*
* // user will expect AsyncZoneSpec wait for
* // then, but because jsonp is not zone aware
* // AsyncZone will finish before then is called.
* });
* });
*/
/**
* Promise for async/fakeAsync zoneSpec test
* can support async operation which not supported by zone.js
* such as
* it ('test jsonp in AsyncZone', async() => {
* new Promise(res => {
* jsonp(url, (data) => {
* // success callback
* res(data);
* });
* }).then((jsonpResult) => {
* // get jsonp result.
*
* // user will expect AsyncZoneSpec wait for
* // then, but because jsonp is not zone aware
* // AsyncZone will finish before then is called.
* });
* });
*/
Zone.__load_patch('promisefortest', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
const symbolState: string = api.symbol('state');
const UNRESOLVED: null = null;
const symbolParentUnresolved = api.symbol('parentUnresolved');

// patch Promise.prototype.then to keep an internal
// number for tracking unresolved chained promise
// we will decrease this number when the parent promise
Expand All @@ -44,15 +44,15 @@ Zone.__load_patch('promisefortest', (global: any, Zone: ZoneType, api: _ZonePriv
}
oriThen = (Promise as any)[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then;
Promise.prototype.then = function() {
const chained = oriThen.apply(this, arguments);
const chained = oriThen.apply(this, arguments);
if (this[symbolState] === UNRESOLVED) {
// parent promise is unresolved.
const asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec');
if (asyncTestZoneSpec) {
asyncTestZoneSpec.unresolvedChainedPromiseCount ++;
asyncTestZoneSpec.unresolvedChainedPromiseCount++;
chained[symbolParentUnresolved] = true;
}
}
}
return chained;
};
};
Expand Down
Loading

0 comments on commit f238908

Please sign in to comment.