WP_HTML_Tag_Processor::after_tag()privateWP 6.2.0

Applies attribute updates and cleans up once a tag is fully parsed.

Method of the class: WP_HTML_Tag_Processor{}

No Hooks.

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->after_tag(): void;

Changelog

Since 6.2.0 Introduced.

WP_HTML_Tag_Processor::after_tag() code WP 6.8

private function after_tag(): void {
	/*
	 * There could be lexical updates enqueued for an attribute that
	 * also exists on the next tag. In order to avoid conflating the
	 * attributes across the two tags, lexical updates with names
	 * need to be flushed to raw lexical updates.
	 */
	$this->class_name_updates_to_attributes_updates();

	/*
	 * Purge updates if there are too many. The actual count isn't
	 * scientific, but a few values from 100 to a few thousand were
	 * tests to find a practically-useful limit.
	 *
	 * If the update queue grows too big, then the Tag Processor
	 * will spend more time iterating through them and lose the
	 * efficiency gains of deferring applying them.
	 */
	if ( 1000 < count( $this->lexical_updates ) ) {
		$this->get_updated_html();
	}

	foreach ( $this->lexical_updates as $name => $update ) {
		/*
		 * Any updates appearing after the cursor should be applied
		 * before proceeding, otherwise they may be overlooked.
		 */
		if ( $update->start >= $this->bytes_already_parsed ) {
			$this->get_updated_html();
			break;
		}

		if ( is_int( $name ) ) {
			continue;
		}

		$this->lexical_updates[] = $update;
		unset( $this->lexical_updates[ $name ] );
	}

	$this->token_starts_at          = null;
	$this->token_length             = null;
	$this->tag_name_starts_at       = null;
	$this->tag_name_length          = null;
	$this->text_starts_at           = 0;
	$this->text_length              = 0;
	$this->is_closing_tag           = null;
	$this->attributes               = array();
	$this->comment_type             = null;
	$this->text_node_classification = self::TEXT_IS_GENERIC;
	$this->duplicate_attributes     = null;
}