WP_HTML_Open_Elements::after_element_push()publicWP 6.4.0

Updates internal flags after adding an element.

Certain conditions (such as "has_p_in_button_scope") are maintained here as flags that are only modified when adding and removing elements. This allows the HTML Processor to quickly check for these conditions instead of iterating over the open stack elements upon each new tag it encounters. These flags, however, need to be maintained as items are added and removed from the stack.

Method of the class: WP_HTML_Open_Elements{}

No Hooks.

Return

null. Nothing (null).

Usage

$WP_HTML_Open_Elements = new WP_HTML_Open_Elements();
$WP_HTML_Open_Elements->after_element_push( $item );
$item(WP_HTML_Token) (required)
Element that was added to the stack of open elements.

Changelog

Since 6.4.0 Introduced.

WP_HTML_Open_Elements::after_element_push() code WP 6.6.2

public function after_element_push( $item ) {
	/*
	 * When adding support for new elements, expand this switch to trap
	 * cases where the precalculated value needs to change.
	 */
	switch ( $item->node_name ) {
		case 'BUTTON':
			$this->has_p_in_button_scope = false;
			break;

		case 'P':
			$this->has_p_in_button_scope = true;
			break;
	}

	if ( null !== $this->push_handler ) {
		( $this->push_handler )( $item );
	}
}