File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -204,18 +204,22 @@ function findElementsInElements(elements = [], selector = '') {
204204}
205205function elementChildren ( element , selector = '' ) {
206206 const children = [ ...element . children ] ;
207- if ( element instanceof HTMLSlotElement ) {
208- children . push ( ...element . assignedElements ( ) )
207+ if ( element instanceof HTMLSlotElement ) {
208+ children . push ( ...element . assignedElements ( ) ) ;
209209 }
210210
211- if ( ! selector ) {
211+ if ( ! selector ) {
212212 return children ;
213213 }
214214 return children . filter ( ( el ) => el . matches ( selector ) ) ;
215215}
216216function elementIsChildOf ( el , parent ) {
217- const children = elementChildren ( parent ) ;
218- return children . includes ( el ) ;
217+ const isChild = parent . contains ( el ) ;
218+ if ( ! isChild && parent instanceof HTMLSlotElement ) {
219+ const children = [ ...element . assignedElements ( ) ] ;
220+ return children . includes ( el ) ;
221+ }
222+ return isChild ;
219223}
220224function showWarning ( text ) {
221225 try {
You can’t perform that action at this time.
0 commit comments