HTML API: `expect_closer()` should report false for self-closing foreign elements.
Previously, `WP_HTML_Processor::expects_closer()` would report `true` for self-closing foreign elements when called without supplying a node in question, but it should have been reporting `true` just as it does for HTML elements. This patch adds a test case demonstrating the issue and a bugfix. The `html5lib` test runner was relying on the incorrect behavior, accidentally working. This is also corrected and the `html5lib` test now relies on the correct behavior of `expects_closer()`. Developed in https://github.com/wordpress/wordpress-develop/pull/7162 Discussed in https://core.trac.wordpress.org/ticket/61576 Follow-up to [58868]. Props: dmsnell. See #61576. Built from https://develop.svn.wordpress.org/trunk@58870 git-svn-id: http://core.svn.wordpress.org/trunk@58266 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ed0e5cff79
commit
7611ec9415
|
@ -786,13 +786,15 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
|||
* or `null` if not matched on any token.
|
||||
*/
|
||||
public function expects_closer( WP_HTML_Token $node = null ): ?bool {
|
||||
$token_name = $node->node_name ?? $this->get_token_name();
|
||||
$token_namespace = $node->namespace ?? $this->get_namespace();
|
||||
$token_name = $node->node_name ?? $this->get_token_name();
|
||||
|
||||
if ( ! isset( $token_name ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$token_namespace = $node->namespace ?? $this->get_namespace();
|
||||
$token_has_self_closing = $node->has_self_closing_flag ?? $this->has_self_closing_flag();
|
||||
|
||||
return ! (
|
||||
// Comments, text nodes, and other atomic tokens.
|
||||
'#' === $token_name[0] ||
|
||||
|
@ -803,7 +805,7 @@ class WP_HTML_Processor extends WP_HTML_Tag_Processor {
|
|||
// Special atomic elements.
|
||||
( 'html' === $token_namespace && in_array( $token_name, array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'SCRIPT', 'STYLE', 'TEXTAREA', 'TITLE', 'XMP' ), true ) ) ||
|
||||
// Self-closing elements in foreign content.
|
||||
( isset( $node ) && 'html' !== $node->namespace && $node->has_self_closing_flag )
|
||||
( 'html' !== $token_namespace && $token_has_self_closing )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -2921,7 +2921,7 @@ class WP_HTML_Tag_Processor {
|
|||
return null;
|
||||
}
|
||||
|
||||
$namespace = $this->get_namespace();
|
||||
$namespace = $this->get_namespace();
|
||||
$lower_name = strtolower( $attribute_name );
|
||||
|
||||
if ( 'math' === $namespace && 'definitionurl' === $lower_name ) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.7-alpha-58868';
|
||||
$wp_version = '6.7-alpha-58870';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue