WP_HTML_Processor::reconstruct_active_formatting_elements(): bool

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness. Use https://html.spec.whatwg.org/#reconstruct-the-active-formatting-elements instead.

Reconstructs the active formatting elements.

Description

This has the effect of reopening all the formatting elements that were opened in the current body, cell, or caption (whichever is youngest) that haven’t been explicitly closed.

See also

Return

bool Whether any formatting elements needed to be reconstructed.

Source

private function reconstruct_active_formatting_elements() {
	/*
	 * > If there are no entries in the list of active formatting elements, then there is nothing
	 * > to reconstruct; stop this algorithm.
	 */
	if ( 0 === $this->state->active_formatting_elements->count() ) {
		return false;
	}

	$last_entry = $this->state->active_formatting_elements->current_node();
	if (

		/*
		 * > If the last (most recently added) entry in the list of active formatting elements is a marker;
		 * > stop this algorithm.
		 */
		'marker' === $last_entry->node_name ||

		/*
		 * > If the last (most recently added) entry in the list of active formatting elements is an
		 * > element that is in the stack of open elements, then there is nothing to reconstruct;
		 * > stop this algorithm.
		 */
		$this->state->stack_of_open_elements->contains_node( $last_entry )
	) {
		return false;
	}

	$this->last_error = self::ERROR_UNSUPPORTED;
	throw new WP_HTML_Unsupported_Exception( 'Cannot reconstruct active formatting elements when advancing and rewinding is required.' );
}

Changelog

VersionDescription
6.4.0Introduced.

User Contributed Notes

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