Changeset 57527
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/html-api/class-wp-html-tag-processor.php
r57506 r57527 2336 2336 // Point this tag processor before the sought tag opener and consume it. 2337 2337 $this->bytes_already_parsed = $this->bookmarks[ $bookmark_name ]->start; 2338 $this->parser_state = self::STATE_READY; 2338 2339 return $this->next_token(); 2339 2340 } -
trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor-bookmark.php
r57508 r57527 436 436 $this->assertFalse( $processor->seek( 'bookmark' ), "$i-th seek() to the bookmark succeeded, even though it should exceed the allowed limit" ); 437 437 } 438 439 /** 440 * Ensures that it's possible to seek to an earlier location in a document even 441 * after reaching the end of a document, when most functionality shuts down. 442 * 443 * @ticket 60428 444 * 445 * @dataProvider data_incomplete_html_with_target_nodes_for_seeking 446 * 447 * @param string $html_with_target_element HTML string containing a tag with a `target` attribute. 448 */ 449 public function test_can_seek_after_document_ends( $html_with_target_element ) { 450 $processor = new WP_HTML_Tag_Processor( $html_with_target_element ); 451 452 $sought_tag_name = null; 453 while ( $processor->next_tag() ) { 454 if ( null !== $processor->get_attribute( 'target' ) ) { 455 $processor->set_bookmark( 'target' ); 456 $sought_tag_name = $processor->get_tag(); 457 } 458 } 459 460 $this->assertTrue( 461 $processor->seek( 'target' ), 462 'Should have been able to seek to the target bookmark after reaching the end of the document.' 463 ); 464 465 $this->assertSame( 466 $sought_tag_name, 467 $processor->get_tag(), 468 "Should have found original target node instead of {$processor->get_tag()}." 469 ); 470 } 471 472 /** 473 * Data provider. 474 * 475 * @return array[]. 476 */ 477 public static function data_incomplete_html_with_target_nodes_for_seeking() { 478 return array( 479 'Compete document' => array( '<div><img target></div>' ), 480 'Incomplete document' => array( '<div><img target></div' ), 481 ); 482 } 438 483 }
Note: See TracChangeset
for help on using the changeset viewer.