Skip to content

Commit

Permalink
Add contains method to open elements
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Jul 17, 2024
1 parent 48c0c96 commit d28d9ec
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/wp-includes/html-api/class-wp-html-open-elements.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,24 @@ public function set_push_handler( Closure $handler ) {
$this->push_handler = $handler;
}

/**
* Reports if a node of a given name is in the stack of open elements.
*
* @since 6.7.0
*
* @param string $node_name Name of node for which to check.
* @return bool Whether a node of the given name is in the stack of open elements.
*/
public function contains( string $node_name ): bool {
foreach ( $this->walk_up() as $item ) {
if ( $node_name === $item->node_name ) {
return true;
}
}

return false;
}

/**
* Reports if a specific node is in the stack of open elements.
*
Expand Down

0 comments on commit d28d9ec

Please sign in to comment.