Skip to content

Commit dc3f1e6

Browse files
committed
try fixes
1 parent 541b4f6 commit dc3f1e6

4 files changed

Lines changed: 28 additions & 41 deletions

File tree

src/wp-includes/html-api/class-wp-html-active-formatting-elements.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class WP_HTML_Active_Formatting_Elements {
4141
*
4242
* @var WP_HTML_Token[]
4343
*/
44-
private $stack = array();
44+
public $stack = array();
4545

4646
/**
4747
* Reports if a specific node is in the stack of active formatting elements.

src/wp-includes/html-api/class-wp-html-open-elements.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class WP_HTML_Open_Elements {
4949
*
5050
* @var bool
5151
*/
52-
private $has_p_in_button_scope = false;
52+
public $has_p_in_button_scope = false;
5353

5454
/**
5555
* A function that will be called when an item is popped off the stack of open elements.

src/wp-includes/html-api/class-wp-html-processor.php

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5286,8 +5286,6 @@ public function seek( $bookmark_name ): bool {
52865286
// Flush any pending updates to the document before beginning.
52875287
$this->get_updated_html();
52885288

5289-
echo 'Seeking to ' . $bookmark_name . "\n";
5290-
52915289
$actual_bookmark_name = "_{$bookmark_name}";
52925290
$processor_started_at = $this->state->current_token
52935291
? $this->bookmarks[ $this->state->current_token->bookmark_name ]->start
@@ -5325,8 +5323,8 @@ public function seek( $bookmark_name ): bool {
53255323
* and computation time.
53265324
*/
53275325
if ( 'backward' === $direction ) {
5328-
echo 'back: ' . "\n";
53295326
// Reset necessary parser state
5327+
$this->change_parsing_namespace( 'html' );
53305328
$this->state->frameset_ok = true;
53315329
$this->state->stack_of_template_insertion_modes = array();
53325330
$this->state->head_element = null;
@@ -5335,64 +5333,55 @@ public function seek( $bookmark_name ): bool {
53355333
$this->element_queue = array();
53365334
$this->current_element = null;
53375335

5338-
if ( null === $this->context_node ) {
5339-
echo 'full parser' . "\n";
5340-
/*
5341-
* In the case of a full parser, the processor needs to be
5342-
* reset to a clean state and start over.
5343-
*/
5344-
$this->state->stack_of_open_elements = new WP_HTML_Open_Elements();
5345-
$this->state->active_formatting_elements = new WP_HTML_Active_Formatting_Elements();
5346-
$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_INITIAL;
5336+
/*
5337+
* In case the parser is a fragment parser, instead of clearing the
5338+
* parser state and starting fresh, calling the stack methods
5339+
* maintains the proper flags in the parser.
5340+
*/
5341+
foreach ( $this->state->stack_of_open_elements->walk_up() as $item ) {
5342+
if ( 'context-node' === $item->bookmark_name ) {
5343+
break;
5344+
}
53475345

5348-
$this->breadcrumbs = array();
5349-
$this->bytes_already_parsed = 0;
5350-
$this->parser_state = self::STATE_READY;
5351-
} else {
5352-
/*
5353-
* In case the parser is a fragment parser, instead of clearing the
5354-
* parser state and starting fresh, calling the stack methods
5355-
* maintains the proper flags in the parser.
5356-
*/
5357-
foreach ( $this->state->stack_of_open_elements->walk_up() as $item ) {
5358-
if ( 'context-node' === $item->bookmark_name ) {
5359-
break;
5360-
}
5346+
$this->state->stack_of_open_elements->remove_node( $item );
5347+
}
53615348

5362-
$this->state->stack_of_open_elements->remove_node( $item );
5349+
foreach ( $this->state->active_formatting_elements->walk_up() as $item ) {
5350+
if ( 'context-node' === $item->bookmark_name ) {
5351+
break;
53635352
}
53645353

5365-
foreach ( $this->state->active_formatting_elements->walk_up() as $item ) {
5366-
if ( 'context-node' === $item->bookmark_name ) {
5367-
break;
5368-
}
5354+
$this->state->active_formatting_elements->remove_node( $item );
5355+
}
53695356

5370-
$this->state->active_formatting_elements->remove_node( $item );
5371-
}
5357+
if ( null === $this->context_node ) {
5358+
$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_INITIAL;
5359+
$this->breadcrumbs = array();
53725360

5361+
$this->bytes_already_parsed = 0;
5362+
$this->parser_state = self::STATE_READY;
5363+
} else {
53735364
parent::seek( 'context-node' );
53745365
$this->state->insertion_mode = WP_HTML_Processor_State::INSERTION_MODE_IN_BODY;
53755366
$this->breadcrumbs = array_slice( $this->breadcrumbs, 0, 2 );
53765367
}
53775368
}
53785369

5379-
53805370
// When moving forwards, reparse the document until reaching the same location as the original bookmark.
53815371
if ( null !== $this->state->current_token && $bookmark_starts_at === $this->bookmarks[ $this->state->current_token->bookmark_name ]->start ) {
53825372
return true;
53835373
}
53845374

5385-
while ( var_dump( $this->next_token() ) ) {
5386-
echo 'bm starts at ' . $bookmark_starts_at . ' and current token starts at ' . $this->bookmarks[ $this->state->current_token->bookmark_name ]->start . "\n";
5387-
if ( $bookmark_starts_at === $this->bookmarks[ $this->state->current_token->bookmark_name ]->start ) {
5375+
while ( $this->next_token() ) {
5376+
$bm = $this->bookmarks[ $this->current_element->token->bookmark_name ];
5377+
if ( $bookmark_starts_at === $bm->start ) {
53885378
while ( isset( $this->current_element ) && WP_HTML_Stack_Event::POP === $this->current_element->operation ) {
53895379
$this->current_element = array_shift( $this->element_queue );
53905380
}
53915381
return true;
53925382
}
53935383
}
53945384

5395-
echo 'false' . "\n";
53965385
return false;
53975386
}
53985387

src/wp-includes/html-api/class-wp-html-tag-processor.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,6 @@ private function base_class_next_token(): bool {
946946
$was_at = $this->bytes_already_parsed;
947947
$this->after_tag();
948948

949-
var_dump( $was_at, $this->parser_state );
950949

951950
// Don't proceed if there's nothing more to scan.
952951
if (
@@ -2544,7 +2543,6 @@ public function has_bookmark( $bookmark_name ): bool {
25442543
* @return bool Whether the internal cursor was successfully moved to the bookmark's location.
25452544
*/
25462545
public function seek( $bookmark_name ): bool {
2547-
var_dump( $bookmark_name, $this->bookmarks );
25482546
if ( ! array_key_exists( $bookmark_name, $this->bookmarks ) ) {
25492547
_doing_it_wrong(
25502548
__METHOD__,

0 commit comments

Comments
 (0)