refactor(platform-browser): Remove setGlobalVar from DOM adapter
This commit is contained in:

committed by
Alex Rickabaugh

parent
d4e196035c
commit
bb2fc6b8da
@ -6,6 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ɵglobal as global} from '@angular/core';
|
||||
|
||||
const CAMEL_CASE_REGEXP = /([A-Z])/g;
|
||||
const DASH_CASE_REGEXP = /-([a-z])/g;
|
||||
|
||||
@ -17,3 +19,19 @@ export function camelCaseToDashCase(input: string): string {
|
||||
export function dashCaseToCamelCase(input: string): string {
|
||||
return input.replace(DASH_CASE_REGEXP, (...m: string[]) => m[1].toUpperCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the value under a given `name` in the global property `ng`. For example `ng.probe` if
|
||||
* `name` is `'probe'`.
|
||||
* @param name Name under which it will be exported. Keep in mind this will be a property of the
|
||||
* global `ng` object.
|
||||
* @param value The value to export.
|
||||
*/
|
||||
export function exportNgVar(name: string, value: any): void {
|
||||
if (!ng) {
|
||||
global['ng'] = ng = (global['ng'] as{[key: string]: any} | undefined) || {};
|
||||
}
|
||||
ng[name] = value;
|
||||
}
|
||||
|
||||
let ng: {[key: string]: any}|undefined;
|
||||
|
Reference in New Issue
Block a user