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 = '') {
204
204
}
205
205
function elementChildren ( element , selector = '' ) {
206
206
const children = [ ...element . children ] ;
207
- if ( element instanceof HTMLSlotElement ) {
208
- children . push ( ...element . assignedElements ( ) )
207
+ if ( element instanceof HTMLSlotElement ) {
208
+ children . push ( ...element . assignedElements ( ) ) ;
209
209
}
210
210
211
- if ( ! selector ) {
211
+ if ( ! selector ) {
212
212
return children ;
213
213
}
214
214
return children . filter ( ( el ) => el . matches ( selector ) ) ;
215
215
}
216
216
function 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 ;
219
223
}
220
224
function showWarning ( text ) {
221
225
try {
You can’t perform that action at this time.
0 commit comments