2016-05-01 22:50:37 -07:00
|
|
|
import {
|
|
|
|
|
DebugNode,
|
|
|
|
|
getDebugNode,
|
|
|
|
|
RootRenderer,
|
|
|
|
|
NgZone,
|
|
|
|
|
ApplicationRef
|
|
|
|
|
} from '@angular/core';
|
2016-04-28 17:50:03 -07:00
|
|
|
import {DebugDomRootRenderer} from '../../../core_private';
|
|
|
|
|
import {assertionsEnabled} from '../../facade/lang';
|
|
|
|
|
import {getDOM} from '../dom_adapter';
|
|
|
|
|
import {DomRootRenderer} from '../dom_renderer';
|
|
|
|
|
|
2016-01-13 21:35:21 -08:00
|
|
|
|
2016-05-20 16:11:49 -07:00
|
|
|
const CORE_TOKENS = {'ApplicationRef': ApplicationRef, 'NgZone': NgZone};
|
2016-01-13 21:35:21 -08:00
|
|
|
|
|
|
|
|
const INSPECT_GLOBAL_NAME = 'ng.probe';
|
2016-02-18 13:51:20 -08:00
|
|
|
const CORE_TOKENS_GLOBAL_NAME = 'ng.coreTokens';
|
2016-01-13 21:35:21 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns a {@link DebugElement} for the given native DOM element, or
|
|
|
|
|
* null if the given native element does not have an Angular view associated
|
|
|
|
|
* with it.
|
|
|
|
|
*/
|
2016-06-08 15:45:15 -07:00
|
|
|
export function inspectNativeElement(element: any /** TODO #9100 */): DebugNode {
|
2016-01-13 21:35:21 -08:00
|
|
|
return getDebugNode(element);
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-08 15:45:15 -07:00
|
|
|
function _createConditionalRootRenderer(rootRenderer: any /** TODO #9100 */) {
|
2016-01-13 21:35:21 -08:00
|
|
|
if (assertionsEnabled()) {
|
|
|
|
|
return _createRootRenderer(rootRenderer);
|
|
|
|
|
}
|
|
|
|
|
return rootRenderer;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-08 15:45:15 -07:00
|
|
|
function _createRootRenderer(rootRenderer: any /** TODO #9100 */) {
|
2016-04-28 17:50:03 -07:00
|
|
|
getDOM().setGlobalVar(INSPECT_GLOBAL_NAME, inspectNativeElement);
|
|
|
|
|
getDOM().setGlobalVar(CORE_TOKENS_GLOBAL_NAME, CORE_TOKENS);
|
2016-01-13 21:35:21 -08:00
|
|
|
return new DebugDomRootRenderer(rootRenderer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Providers which support debugging Angular applications (e.g. via `ng.probe`).
|
|
|
|
|
*/
|
2016-05-20 16:11:49 -07:00
|
|
|
export const ELEMENT_PROBE_PROVIDERS: any[] = [
|
|
|
|
|
{
|
2016-04-25 21:58:48 -07:00
|
|
|
provide: RootRenderer,
|
|
|
|
|
useFactory: _createConditionalRootRenderer,
|
|
|
|
|
deps: [DomRootRenderer]
|
|
|
|
|
}
|
|
|
|
|
];
|
2016-01-13 21:35:21 -08:00
|
|
|
|
2016-05-20 16:11:49 -07:00
|
|
|
export const ELEMENT_PROBE_PROVIDERS_PROD_MODE: any[] = [
|
|
|
|
|
{
|
2016-04-25 21:58:48 -07:00
|
|
|
provide: RootRenderer,
|
|
|
|
|
useFactory: _createRootRenderer,
|
|
|
|
|
deps: [DomRootRenderer]
|
|
|
|
|
}
|
|
|
|
|
];
|