diff options
Diffstat (limited to 'wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php')
-rw-r--r-- | wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php b/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php index 3b2dcb1..590cf96 100644 --- a/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php +++ b/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php @@ -107,7 +107,7 @@ final class WP_Interactivity_API_Directives_Processor extends WP_HTML_Tag_Proces $bookmark = 'append_content_after_template_tag_closer'; $this->set_bookmark( $bookmark ); - $after_closing_tag = $this->bookmarks[ $bookmark ]->start + $this->bookmarks[ $bookmark ]->length + 1; + $after_closing_tag = $this->bookmarks[ $bookmark ]->start + $this->bookmarks[ $bookmark ]->length; $this->release_bookmark( $bookmark ); // Appends the new content. @@ -140,7 +140,7 @@ final class WP_Interactivity_API_Directives_Processor extends WP_HTML_Tag_Proces } list( $opener_tag, $closer_tag ) = $bookmarks; - $after_opener_tag = $this->bookmarks[ $opener_tag ]->start + $this->bookmarks[ $opener_tag ]->length + 1; + $after_opener_tag = $this->bookmarks[ $opener_tag ]->start + $this->bookmarks[ $opener_tag ]->length; $before_closer_tag = $this->bookmarks[ $closer_tag ]->start; if ( $rewind ) { @@ -198,16 +198,19 @@ final class WP_Interactivity_API_Directives_Processor extends WP_HTML_Tag_Proces public function skip_to_tag_closer(): bool { $depth = 1; $tag_name = $this->get_tag(); - while ( $depth > 0 && $this->next_tag( - array( - 'tag_name' => $tag_name, - 'tag_closers' => 'visit', - ) - ) ) { - if ( $this->has_self_closing_flag() ) { - continue; + + while ( $depth > 0 && $this->next_tag( array( 'tag_closers' => 'visit' ) ) ) { + if ( ! $this->is_tag_closer() && $this->get_attribute_names_with_prefix( 'data-wp-' ) ) { + /* translators: 1: SVG or MATH HTML tag. */ + $message = sprintf( __( 'Interactivity directives were detected inside an incompatible %1$s tag. These directives will be ignored in the server side render.' ), $tag_name ); + _doing_it_wrong( __METHOD__, $message, '6.6.0' ); + } + if ( $this->get_tag() === $tag_name ) { + if ( $this->has_self_closing_flag() ) { + continue; + } + $depth += $this->is_tag_closer() ? -1 : 1; } - $depth += $this->is_tag_closer() ? -1 : 1; } return 0 === $depth; |