@@ -51,56 +51,31 @@ this.inspectedNode = class extends ExtensionAPI {
5151 } ;
5252
5353 const _getSubtreeNodes = async ( node ) => {
54- if ( ! node . hasChildren ) {
55- return [ ] ;
56- }
57-
58- const nodes = [ ] ;
59-
60- // At first, get the children cache in nodeFront.
61- let children = await node . treeChildren ( ) ;
62-
63- if ( children . length === 0 ) {
64- // Otherwise, get via the walker.
65- await node . walkerFront . children ( node ) ;
66- children = await node . treeChildren ( ) ;
67- }
68-
69- // We see element type only
70- children = children . filter ( node => node . nodeType === ELEMENT_NODE ) ;
71-
72- for ( const child of children ) {
73- nodes . push ( child ) ;
74- nodes . push ( ...( await _getSubtreeNodes ( child ) ) ) ;
75- }
76-
77- return nodes ;
54+ const result = await node . walkerFront . querySelectorAll ( node , "*" ) ;
55+ return await result . items ( ) ;
7856 }
7957
8058 const _getAppliedStyle = async ( inspector , node , option ) => {
8159 const styles =
8260 await inspector . pageStyle . getApplied ( node , option ) ;
8361
8462 return styles . map ( ( { rule } ) => {
85- const { actorID : ruleId } = rule ;
8663 let { declarations } = rule ;
8764 declarations = declarations . filter ( d => ! d . commentOffsets ) ;
88- return declarations . length
89- ? { ruleId, declarations, node : _getNodeInfo ( node ) }
90- : null ;
91- } ) . filter ( rule => ! ! rule ) ;
65+ return declarations . length ? declarations : null ;
66+ } ) . filter ( declarations => ! ! declarations ) ;
9267 } ;
9368
94- const _getStyle = async ( clientId ) => {
69+ const _getStyle = async ( clientId , actorID , skipPseudo ) => {
9570 await _setupClientIfNeeded ( clientId ) ;
9671
9772 const { inspector } = _clients . get ( clientId ) ;
9873 if ( ! inspector . selection . isConnected ( ) ) {
9974 return [ ] ;
10075 }
10176
102- const node = inspector . selection . nodeFront ;
103- return _getAppliedStyle ( inspector , node , { skipPseudo : true } ) ;
77+ const node = await inspector . walker . conn . getFrontByID ( actorID ) ;
78+ return _getAppliedStyle ( inspector , node , { skipPseudo } ) ;
10479 } ;
10580
10681 const _getStylesInSubtree = async ( clientId ) => {
@@ -120,6 +95,7 @@ this.inspectedNode = class extends ExtensionAPI {
12095
12196 const _getNodeInfo = node => {
12297 const {
98+ actorID,
12399 id,
124100 className,
125101 attributes,
@@ -129,6 +105,7 @@ this.inspectedNode = class extends ExtensionAPI {
129105 } = node ;
130106
131107 return {
108+ actorID,
132109 id,
133110 className : className . trim ( ) ,
134111 attributes,
@@ -185,8 +162,8 @@ this.inspectedNode = class extends ExtensionAPI {
185162 return _getNodesInSubtree ( clientId ) ;
186163 } ,
187164
188- async getStyle ( clientId ) {
189- return _getStyle ( clientId ) ;
165+ async getStyle ( clientId , actorID , skipPseudo ) {
166+ return _getStyle ( clientId , actorID , skipPseudo ) ;
190167 } ,
191168
192169 async getStylesInSubtree ( clientId ) {
0 commit comments