WP_HTML_Processor::is_html_integration_point(): 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/#html-integration-point instead.

Indicates if the current token is an HTML integration point.

Description

Note that this method must be an instance method with access to the current token, since it needs to examine the attributes of the currently-matched tag, if it’s in the MathML namespace.
Otherwise it would be required to scan the HTML and ensure that no other accounting is overlooked.

See also

Return

bool Whether the current token is an HTML integration point.

Source

private function is_html_integration_point(): bool {
	$current_token = $this->state->current_token;
	if ( ! isset( $current_token ) ) {
		return false;
	}

	if ( 'html' === $current_token->namespace ) {
		return false;
	}

	$tag_name = $current_token->node_name;

	if ( 'svg' === $current_token->namespace ) {
		return (
			'DESC' === $tag_name ||
			'FOREIGNOBJECT' === $tag_name ||
			'TITLE' === $tag_name
		);
	}

	if ( 'math' === $current_token->namespace ) {
		if ( 'ANNOTATION-XML' !== $tag_name ) {
			return false;
		}

		$encoding = $this->get_attribute( 'encoding' );

		return (
			is_string( $encoding ) &&
			(
				0 === strcasecmp( $encoding, 'application/xhtml+xml' ) ||
				0 === strcasecmp( $encoding, 'text/html' )
			)
		);
	}

	$this->bail( 'Should not have reached end of HTML Integration Point detection: check HTML API code.' );
	// This unnecessary return prevents tools from inaccurately reporting type errors.
	return false;
}

Changelog

VersionDescription
6.7.0Introduced.

User Contributed Notes

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