This repository has been archived by the owner on Jul 28, 2023. It is now read-only.
SSR: Handle closing tags whose openers had an attribute directive #144
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some attribute directives (such as
wp-context
, see #143), need to be run not only on an opening tag (e.g.<div wp-context="...">
but also on the matching closing one. (Forwp-context
, this is required to reset the context to the value that corresponds to the enclosing scope's context.)This needs somewhat complex logic to keep track of nested tags. Consider e.g. the following example (used in this PR's unit test):
Here, we want to run the
foo-test
attribute directive processor on the closing</div>
that matches the opening<div foo-test="abc">
-- but not on any of the other two closing</div>
s.Rather than requiring individual directive processors to implement the required tracking of nested tags, we implement it in the
wp_process_directives
function.To that end, this PR also moves it into a separate file and changes its signature a bit for better testability. Finally, we're adding a unit test to verify the behavior described above.