diff --git a/php-transformer/src/ArtifactCompiler/ArtifactCompiler.php b/php-transformer/src/ArtifactCompiler/ArtifactCompiler.php
index 4769e2f..a0409ba 100644
--- a/php-transformer/src/ArtifactCompiler/ArtifactCompiler.php
+++ b/php-transformer/src/ArtifactCompiler/ArtifactCompiler.php
@@ -381,6 +381,16 @@ private function scriptDomSelectors(string $script): array
$selectors[(string) $selector] = true;
}
}
+ if ( preg_match_all('/\b(?!document\b)[A-Za-z_$][A-Za-z0-9_$]*\s*\.\s*querySelector(?:All)?\s*\(\s*(["\'])([#.][A-Za-z][A-Za-z0-9_-]*)\1\s*\)/', $script, $matches) ) {
+ foreach ( $matches[2] as $selector ) {
+ $selectors[(string) $selector] = true;
+ }
+ }
+ if ( preg_match_all('/\.\s*closest\s*\(\s*(["\'])([#.][A-Za-z][A-Za-z0-9_-]*)\1\s*\)/', $script, $matches) ) {
+ foreach ( $matches[2] as $selector ) {
+ $selectors[(string) $selector] = true;
+ }
+ }
return array_keys($selectors);
}
diff --git a/php-transformer/tests/fixtures/parity/artifact-runtime-target-container-preservation.json b/php-transformer/tests/fixtures/parity/artifact-runtime-target-container-preservation.json
index aee5d73..f0507f5 100644
--- a/php-transformer/tests/fixtures/parity/artifact-runtime-target-container-preservation.json
+++ b/php-transformer/tests/fixtures/parity/artifact-runtime-target-container-preservation.json
@@ -19,12 +19,12 @@
{
"path": "index.html",
"kind": "html",
- "content": ""
+ "content": "
"
},
{
"path": "js/app.js",
"kind": "js",
- "content": "document.querySelectorAll('.reveal'); const menuShell = document.querySelector('.menu-shell'); menuShell.querySelector('.primary-nav'); document.querySelector('.mobile-nav-overlay'); document.querySelector('.mobile-nav'); document.querySelector('.faq-item'); document.querySelector('.filter-btn').addEventListener('click', function () {}); document.querySelector('.filter-btn').closest('.button-shell'); document.querySelector('.filter-bar'); document.querySelector('.filter-chips'); document.getElementById('note-search'); document.querySelector('.search-input'); document.querySelector('.js-sort-select'); document.querySelector('.js-filter-check'); document.getElementById('contact-form'); document.getElementById('form-success');"
+ "content": "document.querySelectorAll('.reveal'); const menuShell = document.querySelector('.menu-shell'); menuShell.querySelector('.primary-nav'); document.querySelector('.mobile-nav-overlay'); document.querySelector('.mobile-nav'); document.querySelector('.faq-item'); document.querySelector('.filter-btn').addEventListener('click', function () {}); document.querySelector('.filter-btn').closest('.button-shell'); event.target.closest('.card'); document.querySelector('.filter-bar'); document.querySelector('.filter-chips'); document.getElementById('note-search'); document.querySelector('.search-input'); document.querySelector('.js-sort-select'); document.querySelector('.js-filter-check'); document.getElementById('contact-form'); document.getElementById('form-success');"
}
]
}
@@ -32,7 +32,7 @@
"expect": [
{ "path": "status", "assert": "equals", "value": "success_with_warnings" },
{ "path": "source_reports.runtime_dependency_parity.status", "assert": "equals", "value": "pass" },
- { "path": "source_reports.runtime_dependency_parity.dependencies", "assert": "count", "count": 16 },
+ { "path": "source_reports.runtime_dependency_parity.dependencies", "assert": "count", "count": 17 },
{ "path": "serialized_blocks", "assert": "contains", "value": "reveal" },
{ "path": "serialized_blocks", "assert": "contains", "value": "menu-shell" },
{ "path": "serialized_blocks", "assert": "contains", "value": "mobile-nav-overlay" },
@@ -43,6 +43,7 @@
{ "path": "serialized_blocks", "assert": "contains", "value": "button-shell" },
{ "path": "serialized_blocks", "assert": "contains", "value": "filter-bar" },
{ "path": "serialized_blocks", "assert": "contains", "value": "filter-chips" },
+ { "path": "serialized_blocks", "assert": "contains", "value": "card" },
{ "path": "serialized_blocks", "assert": "contains", "value": "note-search" },
{ "path": "serialized_blocks", "assert": "contains", "value": "search-input" },
{ "path": "serialized_blocks", "assert": "contains", "value": "js-sort-select" },