Changeset 58590
- Timestamp:
- 06/28/2024 07:11:25 AM (3 months ago)
- Location:
- branches/6.6
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.6
-
branches/6.6/src/wp-includes/html-api/class-wp-html-open-elements.php
r58441 r58590 309 309 public function pop() { 310 310 $item = array_pop( $this->stack ); 311 312 311 if ( null === $item ) { 313 312 return false; 314 313 } 315 314 315 if ( 'context-node' === $item->bookmark_name ) { 316 $this->stack[] = $item; 317 return false; 318 } 319 316 320 $this->after_element_pop( $item ); 317 321 return true; … … 330 334 public function pop_until( $tag_name ) { 331 335 foreach ( $this->walk_up() as $item ) { 336 if ( 'context-node' === $item->bookmark_name ) { 337 return true; 338 } 339 332 340 $this->pop(); 333 341 … … 370 378 */ 371 379 public function remove_node( $token ) { 380 if ( 'context-node' === $token->bookmark_name ) { 381 return false; 382 } 383 372 384 foreach ( $this->walk_up() as $position_from_end => $item ) { 373 385 if ( $token->bookmark_name !== $item->bookmark_name ) { -
branches/6.6/src/wp-includes/html-api/class-wp-html-processor.php
r58558 r58590 520 520 } 521 521 522 if ( 0 === count( $this->element_queue ) && ! $this->step() ) {523 while ( $this->state->stack_of_open_elements->pop() ) {522 if ( 'done' !== $this->has_seen_context_node && 0 === count( $this->element_queue ) && ! $this->step() ) { 523 while ( 'context-node' !== $this->state->stack_of_open_elements->current_node()->bookmark_name && $this->state->stack_of_open_elements->pop() ) { 524 524 continue; 525 525 } 526 $this->has_seen_context_node = 'done'; 527 return $this->next_token(); 526 528 } 527 529 … … 538 540 539 541 if ( ! isset( $this->current_element ) ) { 540 return $this->next_token(); 542 if ( 'done' === $this->has_seen_context_node ) { 543 return false; 544 } else { 545 return $this->next_token(); 546 } 541 547 } 542 548 … … 783 789 * @since 6.4.0 784 790 * 785 * @todo make aware of queue of elements, because stack operations have already been done by now.786 *787 791 * @return string[]|null Array of tag names representing path to matched node, if matched, otherwise NULL. 788 792 */ 789 793 public function get_breadcrumbs() { 790 794 $breadcrumbs = array(); 795 791 796 foreach ( $this->state->stack_of_open_elements->walk_down() as $stack_item ) { 792 797 $breadcrumbs[] = $stack_item->node_name; 798 } 799 800 if ( ! $this->is_virtual() ) { 801 return $breadcrumbs; 802 } 803 804 foreach ( $this->element_queue as $queue_item ) { 805 if ( $this->current_element->token->bookmark_name === $queue_item->token->bookmark_name ) { 806 break; 807 } 808 809 if ( 'context-node' === $queue_item->token->bookmark_name ) { 810 break; 811 } 812 813 if ( 'real' === $queue_item->provenance ) { 814 break; 815 } 816 817 if ( WP_HTML_Stack_Event::PUSH === $queue_item->operation ) { 818 $breadcrumbs[] = $queue_item->token->node_name; 819 } else { 820 array_pop( $breadcrumbs ); 821 } 822 } 823 824 if ( null !== parent::get_token_name() && ! parent::is_tag_closer() ) { 825 array_pop( $breadcrumbs ); 826 } 827 828 // Add the virtual node we're at. 829 if ( WP_HTML_Stack_Event::PUSH === $this->current_element->operation ) { 830 $breadcrumbs[] = $this->current_element->token->node_name; 793 831 } 794 832 … … 822 860 */ 823 861 public function get_current_depth() { 824 return $this->state->stack_of_open_elements->count(); 862 return $this->is_virtual() 863 ? count( $this->get_breadcrumbs() ) 864 : $this->state->stack_of_open_elements->count(); 825 865 } 826 866
Note: See TracChangeset
for help on using the changeset viewer.