From cd8d8080a8c174d6a30abdbaa6b5e580194af542 Mon Sep 17 00:00:00 2001 From: phcorp Date: Thu, 5 Nov 2026 16:06:53 +0100 Subject: [PATCH] Add regression test for GH-25210 querySelectorAll() returned an element once per matching selector of a selector list. This was fixed by GH-24260, whose test only covers class and :is() selectors; cover selector lists using combinators too. Closes GH-25210 --- .../tests/modern/css_selectors/gh25210.phpt | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 ext/dom/tests/modern/css_selectors/gh25210.phpt diff --git a/ext/dom/tests/modern/css_selectors/gh25210.phpt b/ext/dom/tests/modern/css_selectors/gh25210.phpt new file mode 100644 index 000000000000..4db166d78c49 --- /dev/null +++ b/ext/dom/tests/modern/css_selectors/gh25210.phpt @@ -0,0 +1,33 @@ +--TEST-- +GH-25210 (querySelectorAll() returns duplicates for selector lists with combinators) +--EXTENSIONS-- +dom +--FILE-- +' +); + +foreach ([$dom, $dom->querySelector('ul')] as $context) { + foreach (['ul li, ol li', 'ol li, ul li', 'li, li', 'ul li, ol > li', '#x, ul li'] as $selector) { + $ids = []; + foreach ($context->querySelectorAll($selector) as $node) { + $ids[] = $node->id ?: $node->textContent; + } + echo $selector, ': ', implode(' ', $ids), "\n"; + } +} + +?> +--EXPECT-- +ul li, ol li: ab x +ol li, ul li: ab x +li, li: ab x +ul li, ol > li: ab x +#x, ul li: ab x +ul li, ol li: ab x +ol li, ul li: ab x +li, li: ab x +ul li, ol > li: ab x +#x, ul li: ab x