WP_HTML_Tag_Processor::after_tag()

In this article

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.

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

Source

private function after_tag() {
	/*
	 * 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->duplicate_attributes = null;
}

Changelog

VersionDescription
6.2.0Introduced.

User Contributed Notes

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