Changeset 58870
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/html-api/class-wp-html-processor.php
r58867 r58870 787 787 */ 788 788 public function expects_closer( WP_HTML_Token $node = null ): ?bool { 789 $token_name = $node->node_name ?? $this->get_token_name(); 790 $token_namespace = $node->namespace ?? $this->get_namespace(); 789 $token_name = $node->node_name ?? $this->get_token_name(); 791 790 792 791 if ( ! isset( $token_name ) ) { 793 792 return null; 794 793 } 794 795 $token_namespace = $node->namespace ?? $this->get_namespace(); 796 $token_has_self_closing = $node->has_self_closing_flag ?? $this->has_self_closing_flag(); 795 797 796 798 return ! ( … … 804 806 ( 'html' === $token_namespace && in_array( $token_name, array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'SCRIPT', 'STYLE', 'TEXTAREA', 'TITLE', 'XMP' ), true ) ) || 805 807 // Self-closing elements in foreign content. 806 ( isset( $node ) && 'html' !== $node->namespace && $node->has_self_closing_flag )808 ( 'html' !== $token_namespace && $token_has_self_closing ) 807 809 ); 808 810 } -
trunk/src/wp-includes/html-api/class-wp-html-tag-processor.php
r58867 r58870 2922 2922 } 2923 2923 2924 $namespace = $this->get_namespace();2924 $namespace = $this->get_namespace(); 2925 2925 $lower_name = strtolower( $attribute_name ); 2926 2926 -
trunk/tests/phpunit/tests/html-api/wpHtmlProcessor.php
r58867 r58870 504 504 $this->assertInstanceOf( get_class( $subclass_instance ), $subclass_processor, '::create_fragment did not return subclass instance.' ); 505 505 } 506 507 /** 508 * Ensures that self-closing elements in foreign content properly report 509 * that they expect no closer. 510 * 511 * @ticket 61576 512 */ 513 public function test_expects_closer_foreign_content_self_closing() { 514 $processor = WP_HTML_Processor::create_fragment( '<svg /><math>' ); 515 516 $this->assertTrue( $processor->next_tag() ); 517 $this->assertSame( 'SVG', $processor->get_tag() ); 518 $this->assertFalse( $processor->expects_closer() ); 519 520 $this->assertTrue( $processor->next_tag() ); 521 $this->assertSame( 'MATH', $processor->get_tag() ); 522 $this->assertTrue( $processor->expects_closer() ); 523 } 506 524 } -
trunk/tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php
r58867 r58870 208 208 $tag_indent = $indent_level; 209 209 210 if ( 'html' !== $namespace ) { 211 if ( ! $processor->has_self_closing_flag() ) { 212 ++$indent_level; 213 } 214 } elseif ( ! WP_HTML_Processor::is_void( $tag_name ) ) { 210 if ( $processor->expects_closer() ) { 215 211 ++$indent_level; 216 212 } … … 276 272 $modifiable_text = $processor->get_modifiable_text(); 277 273 if ( '' !== $modifiable_text ) { 278 $output .= str_repeat( $indent, $ indent_level) . "\"{$modifiable_text}\"\n";274 $output .= str_repeat( $indent, $tag_indent + 1 ) . "\"{$modifiable_text}\"\n"; 279 275 } 280 276 … … 282 278 $output .= str_repeat( $indent, $indent_level ) . "content\n"; 283 279 ++$indent_level; 284 }285 286 if ( ! $processor->is_void( $tag_name ) && ! $processor->expects_closer() ) {287 --$indent_level;288 280 } 289 281
Note: See TracChangeset
for help on using the changeset viewer.