1- import { getSetProperties , getComputedCssValues } from "../ui/core/properties" ;
2- import { PercentLength } from "../ui/styling/style-properties" ;
3- import { ViewBase } from "../ui/core/view" ;
4- import { Color } from "../color" ;
51import { CSSComputedStyleProperty } from "./css-agent" ;
62import { InspectorEvents } from "./devtools-elements" ;
73
4+ // Needed for typings only
5+ import { ViewBase } from "../ui/core/view" ;
6+
87const registeredDomNodes = { } ;
98const ELEMENT_NODE_TYPE = 1 ;
109const ROOT_NODE_TYPE = 9 ;
@@ -36,12 +35,19 @@ const propertyBlacklist = [
3635 "nativeView"
3736] ;
3837
39- let inspectorFrontendInstance : any ;
38+ function lazy < T > ( action : ( ) => T ) : ( ) => T {
39+ let _value : T ;
40+ return ( ) => _value || ( _value = action ( ) ) ;
41+ }
42+ const percentLengthToStringLazy = lazy < ( length ) => string > ( ( ) => require ( "../ui/styling/style-properties" ) . PercentLength . convertToString ) ;
43+ const getSetPropertiesLazy = lazy < ( view : ViewBase ) => [ string , any ] [ ] > ( ( ) => require ( "../ui/core/properties" ) . getSetProperties ) ;
44+ const getComputedCssValuesLazy = lazy < ( view : ViewBase ) => [ string , any ] [ ] > ( ( ) => require ( "../ui/core/properties" ) . getComputedCssValues ) ;
4045
4146export function registerInspectorEvents ( inspector : InspectorEvents ) {
4247 inspectorFrontendInstance = inspector ;
4348}
4449
50+ let inspectorFrontendInstance : any ;
4551function notifyInspector ( callback : ( inspector : InspectorEvents ) => void ) {
4652 if ( inspectorFrontendInstance ) {
4753 callback ( inspectorFrontendInstance ) ;
@@ -51,10 +57,8 @@ function notifyInspector(callback: (inspector: InspectorEvents) => void) {
5157function valueToString ( value : any ) : string {
5258 if ( typeof value === "undefined" || value === null ) {
5359 return "" ;
54- } else if ( value instanceof Color ) {
55- return value . toString ( ) ;
5660 } else if ( typeof value === "object" && value . unit ) {
57- return PercentLength . convertToString ( value ) ;
61+ return percentLengthToStringLazy ( ) ( value ) ;
5862 } else {
5963 return value + "" ;
6064 }
@@ -112,7 +116,7 @@ export class DOMNode {
112116
113117 public loadAttributes ( ) {
114118 this . attributes = [ ] ;
115- getSetProperties ( this . viewRef . get ( ) )
119+ getSetPropertiesLazy ( ) ( this . viewRef . get ( ) )
116120 . filter ( propertyFilter )
117121 . forEach ( pair => this . attributes . push ( pair [ 0 ] , pair [ 1 ] + "" ) ) ;
118122
@@ -182,7 +186,7 @@ export class DOMNode {
182186 return [ ] ;
183187 }
184188
185- const result = getComputedCssValues ( view )
189+ const result = getComputedCssValuesLazy ( ) ( view )
186190 . filter ( pair => pair [ 0 ] [ 0 ] !== "_" )
187191 . map ( ( pair ) => {
188192 return {
0 commit comments