[wp-trac] [WordPress Trac] #60768: Interactivity API - SSR context included in void tags shouldn't propagate to following elements
WordPress Trac
noreply at wordpress.org
Wed Mar 13 09:37:08 UTC 2024
#60768: Interactivity API - SSR context included in void tags shouldn't propagate
to following elements
-----------------------------+-----------------------------
Reporter: santosguillamot | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
From my tests, when the same context is used in an inner void tag element
and its parent, it is overwritten when it shouldn't. For example, in this
use case:
{{{
<div data-wp-context='{"text": "outer"}'>
<img data-wp-context='{"text": "inner"}'>
<p data-wp-text="context.text"></p>
</div>
}}}
The last paragraph should receive the parent `div` context "outer" instead
of the `img` "inner.
From what I've seen in the code, this specific case hasn't been considered
while processing `data-wp-context`, and it just removes the context from
the stack when it finds a closing tag.
In my tests, checking if it is a void tag in the directives processing,
and removing the context in that case, seems to solve the issue. Although
I must say I am still unfamiliar with the SSR of the directives.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60768>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list