Make WordPress Core


Ignore:
Timestamp:
07/04/2024 11:14:44 PM (10 months ago)
Author:
dmsnell
Message:

HTML API: Add current_node_is() helper method to stack of open elements.

As part of work to add more spec support to the HTML API, this new method
will make it easier to implement the logic when in the SELECT and TABLE
insertion modes.

Developed in https://github.com/WordPress/wordpress-develop/pull/6968
Discussed in https://core.trac.wordpress.org/ticket/51576

Props dmsnell, jonsurrell.
See #61576.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/html-api/class-wp-html-processor.php

    r58656 r58676  
    10301030
    10311031                $this->generate_implied_end_tags();
    1032                 if ( $this->state->stack_of_open_elements->current_node()->node_name !== $token_name ) {
     1032                if ( ! $this->state->stack_of_open_elements->current_node_is( $token_name ) ) {
    10331033                    // @todo Record parse error: this error doesn't impact parsing.
    10341034                }
     
    10951095                $this->generate_implied_end_tags();
    10961096
    1097                 if ( $this->state->stack_of_open_elements->current_node()->node_name !== $token_name ) {
     1097                if ( ! $this->state->stack_of_open_elements->current_node_is( $token_name ) ) {
    10981098                    // @todo Record parse error: this error doesn't impact parsing.
    10991099                }
     
    11211121                    $node_name = $is_li ? 'LI' : $node->node_name;
    11221122                    $this->generate_implied_end_tags( $node_name );
    1123                     if ( $node_name !== $this->state->stack_of_open_elements->current_node()->node_name ) {
     1123                    if ( ! $this->state->stack_of_open_elements->current_node_is( $node_name ) ) {
    11241124                        // @todo Indicate a parse error once it's possible. This error does not impact the logic here.
    11251125                    }
     
    11981198                $this->generate_implied_end_tags( $token_name );
    11991199
    1200                 if ( $token_name !== $this->state->stack_of_open_elements->current_node()->node_name ) {
     1200                if ( ! $this->state->stack_of_open_elements->current_node_is( $token_name ) ) {
    12011201                    // @todo Indicate a parse error once it's possible. This error does not impact the logic here.
    12021202                }
Note: See TracChangeset for help on using the changeset viewer.