Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ trait ButtonLinkDispatchTrait
*/
private function convertAnchorDispatchElement(DOMElement $element, array &$fallbacks): ?array
{
if ( $this->isRuntimeDomTarget($element) ) {
return $this->htmlPreservationBlock($element);
}

$linkedLogo = $this->linkedSvgLogoBlockFromAnchor($element, $fallbacks);
if ( null !== $linkedLogo ) {
return $linkedLogo;
Expand Down
14 changes: 14 additions & 0 deletions php-transformer/tests/contract/run.php
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,20 @@ public function match(DOMElement $element, PatternContext $context): ?array
$assert(str_contains((string) ($artifactControlIslands[0]['source_snippet'] ?? ''), '<input id="live-filter"'), 'artifact runtime control island preserves source snippet metadata');
$artifactControlRuntimeReport = $artifactControlSelectors['source_reports']['runtime_dependency_parity'] ?? array();
$assert('pass' === ($artifactControlRuntimeReport['status'] ?? ''), 'runtime parity does not flag readable static controls as missing runtime targets');
$artifactRuntimeAnchor = ( new ArtifactCompiler() )->compile(
array(
'entrypoint' => 'index.html',
'files' => array(
'index.html' => '<main><div class="event"><a class="event-add" href="#">Add to calendar</a></div><script src="js/app.js"></script></main>',
'js/app.js' => 'document.querySelectorAll(".event-add").forEach(function (link) { link.addEventListener("click", function (event) { event.preventDefault(); }); });',
),
)
)->toArray();
$artifactRuntimeAnchorMarkup = (string) ($artifactRuntimeAnchor['serialized_blocks'] ?? '');
$artifactRuntimeAnchorIslands = $artifactRuntimeAnchor['source_reports']['runtime_islands'] ?? array();
$assert(str_contains($artifactRuntimeAnchorMarkup, '<!-- wp:html ') && str_contains($artifactRuntimeAnchorMarkup, '<a class="event-add" href="#">Add to calendar</a>'), 'artifact compiler preserves behavior-bearing anchors as exact runtime DOM targets');
$assert(1 === count($artifactRuntimeAnchorIslands) && '.event-add' === ($artifactRuntimeAnchorIslands[0]['selector'] ?? ''), 'artifact compiler reports a behavior-bearing anchor as one bounded runtime DOM island');
$assert('pass' === ($artifactRuntimeAnchor['source_reports']['runtime_dependency_parity']['status'] ?? ''), 'runtime dependency parity resolves behavior-bearing anchor selectors against preserved markup');
$runtimeContext = ( new ArtifactCompiler() )->runtimeContextForSource(
'<header><button class="theme-toggle">Theme</button><script src="js/app.js"></script></header>',
'index.html',
Expand Down
Loading