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

Commit

Permalink
fix(core): fix shorter name closure conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaLiPassion authored and mhevery committed Jan 10, 2018
1 parent 73b0061 commit 00a4e31
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions karma-dist.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = function (config) {
config.files.push('build/test/test_fake_polyfill.js');
config.files.push('build/test/custom_error.js');
config.files.push('dist/zone.js');
config.files.push('dist/zone-patch-user-media.js');
config.files.push('dist/async-test.js');
config.files.push('dist/fake-async-test.js');
config.files.push('dist/long-stack-trace-zone.js');
Expand Down
12 changes: 7 additions & 5 deletions lib/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ export const p = 'object';
export const q = 'number';
export const r = 'string';


// Hack since TypeScript isn't compiling this for a worker.
declare const WorkerGlobalScope: any;

export const zoneSymbol = Zone.__symbol__;
const _global: any = typeof window === p && window || typeof self === p && self || global;
const iw = typeof window !== o;
const w: any = iw ? window : undefined;
const _global: any = iw && w || typeof self === p && self || global;

const REMOVE_ATTRIBUTE = 'removeAttribute';
const NULL_ON_PROP_VALUE: any[] = [null];
Expand Down Expand Up @@ -95,15 +98,14 @@ export const isNode: boolean =
(!('nw' in _global) && typeof _global.process !== o &&
{}.toString.call(_global.process) === '[object process]');

export const isBrowser: boolean =
!isNode && !isWebWorker && !!(typeof window !== o && (window as any)['HTMLElement']);
export const isBrowser: boolean = !isNode && !isWebWorker && !!(iw && w['HTMLElement']);

// we are in electron of nw, so we are both browser and nodejs
// Make sure to access `process` through `_global` so that WebPack does not accidently browserify
// this code.
export const isMix: boolean = typeof _global.process !== o &&
{}.toString.call(_global.process) === '[object process]' && !isWebWorker &&
!!(typeof window !== o && (window as any)['HTMLElement']);
!!(iw && w['HTMLElement']);

const zoneSymbolEventNames: {[eventName: string]: string} = {};

Expand Down Expand Up @@ -430,7 +432,7 @@ export function isIEOrEdge() {
isDetectedIEOrEdge = true;

try {
const ua = window.navigator.userAgent;
const ua = w.navigator.userAgent;
if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) {
ieOrEdge = true;
}
Expand Down
1 change: 0 additions & 1 deletion test/browser/browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2504,7 +2504,6 @@ describe('Zone', function() {
const zone = Zone.current.fork({name: 'media'});
zone.run(() => {
const constraints = {audio: true, video: {width: 1280, height: 720}};

navigator.getUserMedia(
constraints,
() => {
Expand Down
8 changes: 5 additions & 3 deletions test/closure/zone.closure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import '../../dist/zone-node';

const shortKeys = ['w', 'f', 'r', 'rg', 'rt', 'st', 'sc', 'si', 'se', 'ct'];
const testClosureFunction = () => {
const logs: string[] = [];
// call all Zone exposed functions
Expand Down Expand Up @@ -69,7 +69,9 @@ const testClosureFunction = () => {
logs.push('get' + keyZone.get('key'));
logs.push('root' + Zone.root.name);
Object.keys((Zone as any).prototype).forEach(key => {
logs.push(key);
if (shortKeys.indexOf(key) === -1) {
logs.push(key);
}
});
Object.keys(testZoneSpec).forEach(key => {
logs.push(key);
Expand Down Expand Up @@ -139,4 +141,4 @@ process['on']('uncaughtException', (err: any) => {
process['exit'](1);
});

testClosureFunction();
testClosureFunction();

0 comments on commit 00a4e31

Please sign in to comment.