File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1434,11 +1434,11 @@ class Component extends Abstract {
14341434 let me = this ;
14351435
14361436 if ( me . _vdom ) {
1437- let vdomNode = VDomUtil . find ( me . _vdom , data . target . id ) ;
1437+ let vdomNode = VDomUtil . getById ( me . _vdom , data . target . id ) ;
14381438
1439- if ( vdomNode && vdomNode . vdom ) {
1440- vdomNode . vdom . scrollTop = data . scrollTop ;
1441- vdomNode . vdom . scrollLeft = data . scrollLeft
1439+ if ( vdomNode ) {
1440+ vdomNode . scrollTop = data . scrollTop ;
1441+ vdomNode . scrollLeft = data . scrollLeft
14421442 }
14431443 }
14441444 }
Original file line number Diff line number Diff line change @@ -143,6 +143,41 @@ class VDom extends Base {
143143 return VDom . find ( vdom , { flag} ) ?. vdom
144144 }
145145
146+ /**
147+ * Finds a child vdom node inside a vdom tree by a given id
148+ * @param {Object } vdom
149+ * @param {String|null } id
150+ * @returns {Object|null } child vdom node or null
151+ */
152+ static getById ( vdom , id ) {
153+ vdom = VDom . getVdom ( vdom ) ;
154+
155+ let childNodes = vdom . cn || [ ] ,
156+ i = 0 ,
157+ len = childNodes . length ,
158+ childNode ;
159+
160+ if ( vdom . id === id ) {
161+ return vdom
162+ }
163+
164+ for ( ; i < len ; i ++ ) {
165+ childNode = VDom . getVdom ( childNodes [ i ] ) ;
166+
167+ if ( childNode . id === id ) {
168+ return childNode
169+ }
170+
171+ childNode = VDom . getById ( childNode , id ) ;
172+
173+ if ( childNode ) {
174+ return childNode
175+ }
176+ }
177+
178+ return null
179+ }
180+
146181 /**
147182 * Get the ids of all child nodes of the given vdom tree
148183 * @param vdom
You can’t perform that action at this time.
0 commit comments