fix: create proper externs so that closure does not clobber e.g. `ng` for internal variables (#19423)
This commit is contained in:
parent
8a0e45826a
commit
b21a1d1961
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*
|
||||
* @externs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @suppress {duplicate}
|
||||
*/
|
||||
var ng;
|
||||
/**
|
||||
* @suppress {duplicate}
|
||||
*/
|
||||
var wtf;
|
|
@ -21,6 +21,11 @@ const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'unde
|
|||
self instanceof WorkerGlobalScope && self;
|
||||
const __global = typeof global !== 'undefined' && global;
|
||||
const _global: {[name: string]: any} = __window || __global || __self;
|
||||
/**
|
||||
* Attention: whenever providing a new value, be sure to add an
|
||||
* entry into the corresponding `....externs.js` file,
|
||||
* so that closure won't use that global for its purposes.
|
||||
*/
|
||||
export {_global as global};
|
||||
|
||||
// When Symbol.iterator doesn't exist, retrieves the key used in es6-shim
|
||||
|
|
|
@ -6,7 +6,10 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {Inject, Injectable, NgZone, ɵglobal as global} from '@angular/core';
|
||||
import {Inject, Injectable, NgZone} from '@angular/core';
|
||||
// Import zero symbols from zone.js. This causes the zone ambient type to be
|
||||
// added to the type-checker, without emitting any runtime module load statement
|
||||
import {} from 'zone.js';
|
||||
|
||||
import {DOCUMENT} from '../dom_tokens';
|
||||
|
||||
|
@ -18,8 +21,8 @@ import {EventManagerPlugin} from './event_manager';
|
|||
* efficient bookkeeping than Zone can, because we have additional information. This speeds up
|
||||
* addEventListener by 3x.
|
||||
*/
|
||||
const Zone = global['Zone'];
|
||||
const __symbol__ = Zone && Zone['__symbol__'] || function<T>(v: T): T {
|
||||
const __symbol__ =
|
||||
(typeof Zone !== 'undefined') && (Zone as any)['__symbol__'] || function<T>(v: T): T {
|
||||
return v;
|
||||
};
|
||||
const ADD_EVENT_LISTENER: 'addEventListener' = __symbol__('addEventListener');
|
||||
|
@ -32,7 +35,8 @@ const ANGULAR = 'ANGULAR';
|
|||
const NATIVE_ADD_LISTENER = 'addEventListener';
|
||||
const NATIVE_REMOVE_LISTENER = 'removeEventListener';
|
||||
|
||||
const blackListedEvents: string[] = Zone && Zone[__symbol__('BLACK_LISTED_EVENTS')];
|
||||
const blackListedEvents: string[] =
|
||||
(typeof Zone !== 'undefined') && (Zone as any)[__symbol__('BLACK_LISTED_EVENTS')];
|
||||
let blackListedMap: {[eventName: string]: string};
|
||||
if (blackListedEvents) {
|
||||
blackListedMap = {};
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*
|
||||
* @externs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @suppress {duplicate}
|
||||
*/
|
||||
var getAngularTestability;
|
||||
/**
|
||||
* @suppress {duplicate}
|
||||
*/
|
||||
var getAllAngularTestabilities;
|
||||
/**
|
||||
* @suppress {duplicate}
|
||||
*/
|
||||
var getAllAngularRootElements;
|
||||
/**
|
||||
* @suppress {duplicate}
|
||||
*/
|
||||
var frameworkStabilizers;
|
Loading…
Reference in New Issue