mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Previously, you could inspect the source code of a component but not a directive. This commit adds functionality to inspect source code for directives as well. Now you will see the inspect icon on the header component of each directive on a selected element. PR Close #47334
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC 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
|
|
*/
|
|
|
|
/// <reference types="chrome"/>
|
|
|
|
import {ApplicationOperations} from 'ng-devtools';
|
|
import {DirectivePosition, ElementPosition} from 'protocol';
|
|
|
|
export class ChromeApplicationOperations extends ApplicationOperations {
|
|
viewSource(position: ElementPosition, directiveIndex: number): void {
|
|
if (chrome.devtools) {
|
|
chrome.devtools.inspectedWindow.eval(
|
|
`inspect(inspectedApplication.findConstructorByPosition('${position}', ${
|
|
directiveIndex}))`);
|
|
}
|
|
}
|
|
|
|
selectDomElement(position: ElementPosition): void {
|
|
if (chrome.devtools) {
|
|
chrome.devtools.inspectedWindow.eval(
|
|
`inspect(inspectedApplication.findDomElementByPosition('${position}'))`);
|
|
}
|
|
}
|
|
|
|
inspect(directivePosition: DirectivePosition, objectPath: string[]): void {
|
|
if (chrome.devtools) {
|
|
const args = {
|
|
directivePosition,
|
|
objectPath,
|
|
};
|
|
chrome.devtools.inspectedWindow.eval(
|
|
`inspect(inspectedApplication.findPropertyByPosition('${JSON.stringify(args)}'))`);
|
|
}
|
|
}
|
|
}
|