mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
HTML API: Add support for SPAN element.
In this patch we're introducing support for the SPAN element, which is the first in the class of "any other tag" in the "in body" insertion mode. This patch introduces the mechanisms required to handle that class of tags but only introduces SPAN to keep the change focused. With the tests and mechanisms in place it will be possible to follow-up and add another limited set of tags. It's important that this not use the default catch-all in the switch handling `step_in_body` because that would catch tags that have specific rules in previous case statements that aren't yet added. For example, we don't want to treat the `TABLE` element as "any other tag". Props dmsnell. Fixes #58907. Built from https://develop.svn.wordpress.org/trunk@56331 git-svn-id: http://core.svn.wordpress.org/trunk@55843 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6359762e66
commit
8fa9aad5e6
@ -626,6 +626,37 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
||||
$this->insert_html_element( $this->current_token );
|
||||
return true;
|
||||
|
||||
/*
|
||||
* > Any other start tag
|
||||
*/
|
||||
case '+SPAN':
|
||||
$this->reconstruct_active_formatting_elements();
|
||||
$this->insert_html_element( $this->current_token );
|
||||
return true;
|
||||
|
||||
/*
|
||||
* Any other end tag
|
||||
*/
|
||||
case '-SPAN':
|
||||
foreach ( $this->state->stack_of_open_elements->walk_up() as $item ) {
|
||||
// > If node is an HTML element with the same tag name as the token, then:
|
||||
if ( $item->node_name === $tag_name ) {
|
||||
$this->generate_implied_end_tags( $tag_name );
|
||||
|
||||
// > If node is not the current node, then this is a parse error.
|
||||
|
||||
$this->state->stack_of_open_elements->pop_until( $tag_name );
|
||||
return true;
|
||||
}
|
||||
|
||||
// > Otherwise, if node is in the special category, then this is a parse error; ignore the token, and return.
|
||||
if ( self::is_special( $item->node_name ) ) {
|
||||
return $this->step();
|
||||
}
|
||||
}
|
||||
// Execution should not reach here; if it does then something went wrong.
|
||||
return false;
|
||||
|
||||
default:
|
||||
$this->last_error = self::ERROR_UNSUPPORTED;
|
||||
throw new WP_HTML_Unsupported_Exception( "Cannot process {$tag_name} element." );
|
||||
@ -873,7 +904,7 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
||||
*
|
||||
* @since 6.4.0
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws WP_HTML_Unsupported_Exception
|
||||
*
|
||||
* @see https://html.spec.whatwg.org/#generate-implied-end-tags
|
||||
*
|
||||
@ -893,6 +924,26 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Closes elements that have implied end tags, thoroughly.
|
||||
*
|
||||
* See the HTML specification for an explanation why this is
|
||||
* different from {@see WP_HTML_Processor::generate_implied_end_tags}.
|
||||
*
|
||||
* @since 6.4.0
|
||||
*
|
||||
* @see https://html.spec.whatwg.org/#generate-implied-end-tags
|
||||
*/
|
||||
private function generate_implied_end_tags_thoroughly() {
|
||||
$elements_with_implied_end_tags = array(
|
||||
'P',
|
||||
);
|
||||
|
||||
while ( in_array( $this->state->stack_of_open_elements->current_node(), $elements_with_implied_end_tags, true ) ) {
|
||||
$this->state->stack_of_open_elements->pop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconstructs the active formatting elements.
|
||||
*
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.4-alpha-56329';
|
||||
$wp_version = '6.4-alpha-56331';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user