Changeset 59502
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/html-api/class-wp-html-processor.php
r59500 r59502 304 304 305 305 while ( $context_processor->next_tag() ) { 306 $context_processor->set_bookmark( 'final_node' ); 306 if ( ! $context_processor->is_virtual() ) { 307 $context_processor->set_bookmark( 'final_node' ); 308 } 307 309 } 308 310 … … 5674 5676 * HTML structure or unwanted processing overhead. 5675 5677 * 5678 * Bookmarks cannot be set on tokens that do no appear in the original 5679 * HTML text. For example, the HTML `<table><td>` stops at tags `TABLE`, 5680 * `TBODY`, `TR`, and `TD`. The `TBODY` and `TR` tags do not appear in 5681 * the original HTML and cannot be used as bookmarks. 5682 * 5676 5683 * @since 6.4.0 5677 5684 * … … 5680 5687 */ 5681 5688 public function set_bookmark( $bookmark_name ): bool { 5689 if ( $this->is_virtual() ) { 5690 _doing_it_wrong( 5691 __METHOD__, 5692 __( 'Cannot set bookmarks on tokens that do no appear in the original HTML text.' ), 5693 '6.8.0' 5694 ); 5695 return false; 5696 } 5682 5697 return parent::set_bookmark( "_{$bookmark_name}" ); 5683 5698 } -
trunk/tests/phpunit/tests/html-api/wpHtmlProcessor-bookmark.php
r59391 r59502 158 158 ); 159 159 } 160 161 /** 162 * @ticket 62521 163 * 164 * @expectedIncorrectUsage WP_HTML_Processor::set_bookmark 165 */ 166 public function test_bookmarks_not_allowed_on_virtual_nodes() { 167 $processor = WP_HTML_Processor::create_full_parser( 'text' ); 168 $this->assertTrue( $processor->next_tag( 'BODY' ) ); 169 $this->assertFalse( $processor->set_bookmark( 'mark' ) ); 170 $this->assertTrue( $processor->next_token() ); 171 $this->assertTrue( $processor->set_bookmark( 'mark' ) ); 172 } 160 173 }
Note: See TracChangeset
for help on using the changeset viewer.