Skip to content

Commit 05801bb

Browse files
committed
Merge branch 'trunk' into html-api/add-spawn-fragment-parser-method
2 parents 9e11f19 + 44e6c75 commit 05801bb

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,17 @@
179179
"grunt": "grunt",
180180
"lint:jsdoc": "wp-scripts lint-js",
181181
"lint:jsdoc:fix": "wp-scripts lint-js --fix",
182-
"env:start": "node ./tools/local-env/scripts/start.js && node ./tools/local-env/scripts/docker.js run -T php composer update -W",
182+
"env:start": "node ./tools/local-env/scripts/start.js && node ./tools/local-env/scripts/docker.js run -T --rm php composer update -W",
183183
"env:stop": "node ./tools/local-env/scripts/docker.js down",
184184
"env:restart": "npm run env:stop && npm run env:start",
185185
"env:clean": "node ./tools/local-env/scripts/docker.js down -v --remove-orphans",
186186
"env:reset": "node ./tools/local-env/scripts/docker.js down --rmi all -v --remove-orphans",
187187
"env:install": "node ./tools/local-env/scripts/install.js",
188-
"env:cli": "node ./tools/local-env/scripts/docker.js run cli",
188+
"env:cli": "node ./tools/local-env/scripts/docker.js run --rm cli",
189189
"env:logs": "node ./tools/local-env/scripts/docker.js logs",
190190
"env:pull": "node ./tools/local-env/scripts/docker.js pull",
191191
"test:performance": "wp-scripts test-playwright --config tests/performance/playwright.config.js",
192-
"test:php": "node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit",
192+
"test:php": "node ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpunit",
193193
"test:coverage": "npm run test:php -- --coverage-html ./coverage/html/ --coverage-php ./coverage/php/report.php --coverage-text=./coverage/text/report.txt",
194194
"test:e2e": "wp-scripts test-playwright --config tests/e2e/playwright.config.js",
195195
"test:visual": "wp-scripts test-playwright --config tests/visual-regression/playwright.config.js",

src/wp-includes/html-api/class-wp-html-processor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ public function expects_closer( ?WP_HTML_Token $node = null ): ?bool {
928928
// Doctype declarations.
929929
'html' === $token_name ||
930930
// Void elements.
931-
self::is_void( $token_name ) ||
931+
( 'html' === $token_namespace && self::is_void( $token_name ) ) ||
932932
// Special atomic elements.
933933
( 'html' === $token_namespace && in_array( $token_name, array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'SCRIPT', 'STYLE', 'TEXTAREA', 'TITLE', 'XMP' ), true ) ) ||
934934
// Self-closing elements in foreign content.

tests/phpunit/tests/html-api/wpHtmlProcessor.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,31 @@ public function test_expects_closer_foreign_content_self_closing() {
561561
$this->assertTrue( $processor->expects_closer() );
562562
}
563563

564+
/**
565+
* Ensures that expects_closer works for void-like elements in foreign content.
566+
*
567+
* For example, `<svg><input>text` creates an `svg:input` that contains a text node.
568+
* This input should not be treated as a void tag and _should_ expect a close tag.
569+
*
570+
* @dataProvider data_void_tags
571+
*
572+
* @ticket 62363
573+
*/
574+
public function test_expects_closer_foreign_content_not_void( string $void_tag ) {
575+
$processor = WP_HTML_Processor::create_fragment( "<svg><{$void_tag}>" );
576+
577+
$this->assertTrue( $processor->next_tag( $void_tag ) );
578+
579+
// Some void-like tags will close the SVG element and be HTML tags.
580+
if ( $processor->get_namespace() === 'svg' ) {
581+
$this->assertSame( array( 'HTML', 'BODY', 'SVG', $void_tag ), $processor->get_breadcrumbs() );
582+
$this->assertTrue( $processor->expects_closer() );
583+
} else {
584+
$this->assertSame( array( 'HTML', 'BODY', $void_tag ), $processor->get_breadcrumbs() );
585+
$this->assertFalse( $processor->expects_closer() );
586+
}
587+
}
588+
564589
/**
565590
* Ensures that self-closing foreign SCRIPT elements are properly found.
566591
*

0 commit comments

Comments
 (0)