@@ -3,7 +3,7 @@ cls.EcmascriptDebugger || (cls.EcmascriptDebugger = {});
33cls . EcmascriptDebugger [ "6.0" ] || ( cls . EcmascriptDebugger [ "6.0" ] = { } ) ;
44
55/**
6- * @constructor
6+ * @constructor
77 */
88
99cls . EcmascriptDebugger [ "6.0" ] . InspectableDOMNode = function ( rt_id ,
@@ -33,19 +33,19 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.PSEUDO_NODE = 0;
3333
3434cls . EcmascriptDebugger [ "6.0" ] . InspectableDOMNode . prototype = new function ( )
3535{
36-
37- const
36+
37+ const
3838 NODE_LIST = 0 ,
39- ID = 0 ,
40- TYPE = 1 ,
41- NAME = 2 ,
39+ ID = 0 ,
40+ TYPE = 1 ,
41+ NAME = 2 ,
4242 DEPTH = 3 ,
4343
4444 ATTRS = 5 ,
4545 ATTR_PREFIX = 0 ,
46- ATTR_KEY = 1 ,
46+ ATTR_KEY = 1 ,
4747 ATTR_VALUE = 2 ,
48- CHILDREN_LENGTH = 6 ,
48+ CHILDREN_LENGTH = 6 ,
4949 PUBLIC_ID = 4 ,
5050 SYSTEM_ID = 5 ,
5151 MATCH_REASON = cls . EcmascriptDebugger [ "6.0" ] . InspectableDOMNode . MATCH_REASON ,
@@ -104,14 +104,14 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype = new function()
104104 this . search = function ( query , type , ignore_case , object_id , cb )
105105 {
106106 this . _isprocessing = true ;
107- var tag = window . tag_manager . set_callback ( this ,
108- this . __handle_dom ,
107+ var tag = window . tag_manager . set_callback ( this ,
108+ this . __handle_dom ,
109109 [ object_id , TRAVERSE_SEARCH , cb ] ) ;
110110 this . search_type = type ;
111- var msg = [ this . _data_runtime_id ,
112- query ,
113- type ,
114- object_id || null ,
111+ var msg = [ this . _data_runtime_id ,
112+ query ,
113+ type ,
114+ object_id || null ,
115115 ignore_case || 0 ] ;
116116 services [ 'ecmascript-debugger' ] . requestSearchDom ( tag , msg ) ;
117117 } ;
@@ -139,6 +139,16 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype = new function()
139139 } ;
140140 } ;
141141
142+ this . node_has_attr = function ( node_id , attr_name )
143+ {
144+ var node = this . get_node ( node_id ) ;
145+ var attrs = node && node [ ATTRS ] ;
146+ return attrs && attrs . some ( function ( attr )
147+ {
148+ return attr [ ATTR_KEY ] == attr_name ;
149+ } ) ;
150+ }
151+
142152 this . _get_dom = function ( object_id , traverse_type , cb )
143153 {
144154 this . _isprocessing = true ;
@@ -149,11 +159,11 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype = new function()
149159 this . __handle_dom = function ( status , message , object_id , traverse_type , cb )
150160 {
151161 var
152- _data = message [ NODE_LIST ] || [ ] ,
162+ _data = message [ NODE_LIST ] || [ ] ,
153163 error_ms = ui_strings . S_DRAGONFLY_INFO_MESSAGE + 'this.__handle_dom failed in DOMBaseData' ,
154164 splice_args = null ,
155165 i = 0 ;
156-
166+
157167 if ( ! status )
158168 {
159169 switch ( traverse_type )
@@ -163,7 +173,7 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype = new function()
163173 case "parent-node-chain-with-children" :
164174 {
165175 if ( traverse_type != "search" || ! object_id )
166- {
176+ {
167177 this . _data = _data ;
168178 this . _unfold_pseudos ( ) ;
169179 break ;
@@ -176,12 +186,12 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype = new function()
176186 for ( ; this . _data [ i ] && this . _data [ i ] [ ID ] != object_id ; i ++ ) ;
177187 if ( this . _data [ i ] )
178188 {
179- // A search with an object_id searches only in the subtree
180- // of that node, but returns a tree with the ancestor up
189+ // A search with an object_id searches only in the subtree
190+ // of that node, but returns a tree with the ancestor up
181191 // to the document.
182- // For the use case in Dragonfly we cut away the chain from
192+ // For the use case in Dragonfly we cut away the chain from
183193 // the object up to the document.
184- if ( traverse_type == "search" )
194+ if ( traverse_type == "search" )
185195 {
186196 this . clear_search ( ) ;
187197 for ( var j = 0 ; _data [ j ] && _data [ j ] [ ID ] != object_id ; j ++ ) ;
@@ -190,11 +200,11 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype = new function()
190200 _data = _data . slice ( j ) ;
191201 }
192202 }
193- // if object_id matches the one of the first node
203+ // if object_id matches the one of the first node
194204 // of the return data the traversal was subtree
195- // a search can return no data
205+ // a search can return no data
196206 if ( _data [ 0 ] )
197- {
207+ {
198208 if ( object_id == _data [ 0 ] [ ID ] )
199209 {
200210 this . collapse ( object_id ) ;
@@ -204,7 +214,7 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype = new function()
204214 {
205215 this . _data . insert ( i + 1 , _data ) ;
206216 }
207-
217+
208218 }
209219 this . _unfold_pseudos ( i , _data . length , traverse_type == "subtree" ) ;
210220 }
@@ -258,7 +268,7 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype = new function()
258268 if ( cur [ DEPTH ] > current_depth )
259269 {
260270 parent_stack . push ( this . _data [ i + delta - 1 ] ) ;
261- delta += this . _insert_pseudos ( parent_stack . last ,
271+ delta += this . _insert_pseudos ( parent_stack . last ,
262272 i + delta ,
263273 BEFORE_ALIKES ) ;
264274 current_depth ++ ;
@@ -267,15 +277,15 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype = new function()
267277 {
268278 while ( cur [ DEPTH ] < current_depth )
269279 {
270- delta += this . _insert_pseudos ( parent_stack . last ,
280+ delta += this . _insert_pseudos ( parent_stack . last ,
271281 i + delta ,
272282 AFTER_ALIKES ) ;
273283 parent_stack . pop ( ) ;
274284 current_depth -- ;
275285 }
276286 }
277287
278- if ( ! cur [ CHILDREN_LENGTH ] &&
288+ if ( ! cur [ CHILDREN_LENGTH ] &&
279289 ( force_unfold || current_depth == this . _data [ index ] [ DEPTH ] ) )
280290 {
281291 delta += this . _insert_pseudos ( cur , i + delta + 1 , BEFORE_ALIKES ) ;
@@ -333,7 +343,7 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype = new function()
333343 level = this . _data [ i ] [ DEPTH ] ;
334344 i += 1 ;
335345 j = i ;
336- while ( this . _data [ j ] && this . _data [ j ] [ DEPTH ] > level )
346+ while ( this . _data [ j ] && this . _data [ j ] [ DEPTH ] > level )
337347 j ++ ;
338348 if ( j - i )
339349 {
@@ -342,7 +352,7 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype = new function()
342352 }
343353 else
344354 {
345- opera . postError ( ui_strings . S_DRAGONFLY_INFO_MESSAGE +
355+ opera . postError ( ui_strings . S_DRAGONFLY_INFO_MESSAGE +
346356 'missing refrence in collapse_node in DOMBaseData' ) ;
347357 }
348358 } ;
@@ -356,7 +366,7 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype = new function()
356366 {
357367 for ( var attr , i = 0 ; attr = attrs [ i ] ; i ++ )
358368 {
359- if ( attr [ ATTR_KEY ] == 'id' )
369+ if ( attr [ ATTR_KEY ] == 'id' )
360370 id = "#" + attr [ ATTR_VALUE ] ;
361371 if ( attr [ ATTR_KEY ] == 'class' && attr [ ATTR_VALUE ] . trim ( ) )
362372 class_name = "." + attr [ ATTR_VALUE ] . trim ( ) . replace ( / \s + / g, "." ) ;
@@ -374,7 +384,7 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype = new function()
374384 if ( cur )
375385 ret = cur [ 1 ] == '1' ;
376386 else
377- opera . postError ( ui_strings . S_DRAGONFLY_INFO_MESSAGE +
387+ opera . postError ( ui_strings . S_DRAGONFLY_INFO_MESSAGE +
378388 "failed in this._parse_parent_offset in InspectableDOMNode" ) ;
379389 }
380390 return ret ;
@@ -439,7 +449,7 @@ cls.EcmascriptDebugger["6.0"].InspectableDOMNode.prototype = new function()
439449 {
440450 return Boolean ( this . _data && this . _data . length ) ;
441451 }
442-
452+
443453 this . get_node = function ( node_id )
444454 {
445455 if ( this . has_data ( ) )
0 commit comments