Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0f8008e
Add append_content_after_closing_tag_on_balanced_or_void_tags method
luisherranz Jan 29, 2024
2c70fb8
Make next_balanced_tag_closer_tag public and add tests
luisherranz Jan 30, 2024
093bb36
Add compat for array_is_list added in WP 6.5
luisherranz Jan 30, 2024
e378aad
Add missing covers in wp-text tests
luisherranz Jan 30, 2024
767b9aa
Minor fixes to the Interactivity API directive processor
luisherranz Jan 30, 2024
106eee6
Create internal method process_directives_args to call it from wp-each
luisherranz Jan 30, 2024
58abeb0
Add kebab-case to camelCase method
luisherranz Jan 30, 2024
4a62bb6
Add wp-each processor
luisherranz Jan 31, 2024
29f10fa
Make sure it doesn't process non-array values
luisherranz Jan 31, 2024
527a828
Merge branch 'trunk' into add/data-wp-each-server-directive-processor
luisherranz Jan 31, 2024
3b67d47
Trim before checking that starts and ends with tags
luisherranz Jan 31, 2024
72a2f19
Fix typo and some extra tabs
luisherranz Jan 31, 2024
5f3082c
Fix PHPCS
luisherranz Jan 31, 2024
a20240d
Add kebal to camel case conversion in the JS runtime
luisherranz Jan 31, 2024
fa33e6e
Add extra nested test
luisherranz Feb 2, 2024
ed4319e
Restrict appending to template tags
luisherranz Feb 3, 2024
b25a04c
Merge branch 'trunk' into add/data-wp-each-server-directive-processor
luisherranz Feb 3, 2024
f347057
Override WP Core script modules
luisherranz Feb 3, 2024
f434acc
Switch to `data-wp-remove` directive
luisherranz Feb 3, 2024
42d6404
Rename back to data-wp-each-child
luisherranz Feb 4, 2024
b1fd904
Merge branch 'trunk' into add/data-wp-each-server-directive-processor
luisherranz Feb 4, 2024
56f373e
Add missing continue in foreach loop
luisherranz Feb 4, 2024
62d19c4
Don't return a value
luisherranz Feb 4, 2024
f9a2731
Merge branch 'trunk' into add/data-wp-each-server-directive-processor
luisherranz Feb 4, 2024
8fda776
Transform interactivity index to TS
luisherranz Feb 4, 2024
bd858e6
Fix includes_url logic
luisherranz Feb 4, 2024
628509a
Also move vdom to TS
luisherranz Feb 4, 2024
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
Prev Previous commit
Next Next commit
Create internal method process_directives_args to call it from wp-each
  • Loading branch information
luisherranz committed Jan 30, 2024
commit 106eee6e134f91f4b8d7b18a3c766e2f722e4205
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,30 @@ public function add_hooks() {
* @return string The processed HTML content. It returns the original content when the HTML contains unbalanced tags.
*/
public function process_directives( string $html ): string {
$p = new WP_Interactivity_API_Directives_Processor( $html );
$tag_stack = array();
$namespace_stack = array();
$context_stack = array();
$unbalanced = false;
$namespace_stack = array();
$result = $this->process_directives_args( $html, $context_stack, $namespace_stack );
return null === $result ? $html : $result;
}

/**
* Processes the interactivity directives contained within the HTML content
* and updates the markup accordingly.
*
* It needs the context and namespace stacks to be passed by reference and
* it returns null if the HTML contains unbalanced tags.
*
* @since 6.5.0
*
* @param string $html The HTML content to process.
* @param array $context_stack The reference to the array used to keep track of contexts during processing.
* @param array $namespace_stack The reference to the array used to manage namespaces during processing.
* @return string|null The processed HTML content. It returns null when the HTML contains unbalanced tags.
*/
private function process_directives_args( string $html, array &$context_stack, array &$namespace_stack ) {
$p = new WP_Interactivity_API_Directives_Processor( $html );
$tag_stack = array();
$unbalanced = false;

$directive_processor_prefixes = array_keys( self::$directive_processors );
$directive_processor_prefixes_reversed = array_reverse( $directive_processor_prefixes );
Expand Down Expand Up @@ -266,11 +285,11 @@ public function process_directives( string $html ): string {
}

/*
* It returns the original content if the HTML is unbalanced because
* unbalanced HTML is not safe to process. In that case, the Interactivity
* API runtime will update the HTML on the client side during the hydration.
* It returns null if the HTML is unbalanced because unbalanced HTML is
* not safe to process. In that case, the Interactivity API runtime will
* update the HTML on the client side during the hydration.
*/
return $unbalanced || 0 < count( $tag_stack ) ? $html : $p->get_updated_html();
return $unbalanced || 0 < count( $tag_stack ) ? null : $p->get_updated_html();
}

/**
Expand Down