WP_HTML_Open_Elements::has_element_in_select_scope( string $tag_name ): bool

Returns whether a particular element is in select scope.

Description

This test differs from the others like it, in that its rules are inverted.
Instead of arriving at a match when one of any tag in a termination group is reached, this one terminates if any other tag is reached.

The stack of open elements is said to have a particular element in select scope when it has that element in the specific scope consisting of all element types except the following:

  • optgroup in the HTML namespace
  • option in the HTML namespace

See also

Parameters

$tag_namestringrequired
Name of tag to check.

Return

bool Whether the given element is in SELECT scope.

Source

public function has_element_in_select_scope( string $tag_name ): bool {
	foreach ( $this->walk_up() as $node ) {
		if ( $node->node_name === $tag_name ) {
			return true;
		}

		if (
			'OPTION' !== $node->node_name &&
			'OPTGROUP' !== $node->node_name
		) {
			return false;
		}
	}

	return false;
}

Changelog

VersionDescription
6.7.0Full implementation.
6.4.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.