Skip to content

Commit 74efd7f

Browse files
committed
test(modal): reverting to for loop search for shallow nested objects because stencil's test mock doesn't support :scope
1 parent 4278133 commit 74efd7f

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

core/src/components/modal/modal.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,10 +1464,18 @@ export class Modal implements ComponentInterface, OverlayInterface {
14641464
// Check for standard Ionic layout children (ion-content, ion-footer),
14651465
// searching one level deep for wrapped components (e.g.,
14661466
// <app-footer><ion-footer>...</ion-footer></app-footer>).
1467-
// Uses :scope to limit the search depth rather than matching deeply
1468-
// nested elements inside inner modals or other overlays.
1469-
const hasContent = el.querySelector(':scope > ion-content, :scope > * > ion-content') !== null;
1470-
const hasFooter = el.querySelector(':scope > ion-footer, :scope > * > ion-footer') !== null;
1467+
// Note: uses a manual loop instead of querySelector(':scope > ...') because
1468+
// Stencil's mock-doc (used in spec tests) does not support :scope.
1469+
let hasContent = false;
1470+
let hasFooter = false;
1471+
for (const child of Array.from(el.children)) {
1472+
if (child.tagName === 'ION-CONTENT') hasContent = true;
1473+
if (child.tagName === 'ION-FOOTER') hasFooter = true;
1474+
for (const grandchild of Array.from(child.children)) {
1475+
if (grandchild.tagName === 'ION-CONTENT') hasContent = true;
1476+
if (grandchild.tagName === 'ION-FOOTER') hasFooter = true;
1477+
}
1478+
}
14711479

14721480
// Only apply wrapper padding for standard Ionic layouts (has ion-content
14731481
// but no ion-footer). Custom modals with raw HTML are fully

0 commit comments

Comments
 (0)