Skip to content

Commit 27a9781

Browse files
committed
Rename method, use static constructor, add comments
1 parent 9d3b318 commit 27a9781

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,23 @@ function ( WP_HTML_Token $token ): void {
425425
}
426426

427427
/**
428-
* Creates a fragment processor with the current node as its context element.
428+
* Creates a fragment processor at the current node.
429+
*
430+
* HTML Fragment parsing always happens with a context node. HTML Fragment Processors can be
431+
* instantiated with a `BODY` context node via `WP_HTML_Processor::create_fragment()`.
432+
*
433+
* The context node may impact how a fragment of HTML is parsed. For example, when parsing
434+
* `<rect />A</rect>B`:
435+
*
436+
* With a BODY context node results in the following tree:
437+
*
429438
*
430439
* @see https://html.spec.whatwg.org/multipage/parsing.html#html-fragment-parsing-algorithm
431440
*
432441
* @param string $html Input HTML fragment to process.
433442
* @return static|null The created processor if successful, otherwise null.
434443
*/
435-
public function spawn_fragment_parser( string $html ): ?self {
444+
public function create_fragment_at_current_node( string $html ) {
436445
if ( $this->get_token_type() !== '#tag' ) {
437446
return null;
438447
}
@@ -452,7 +461,7 @@ public function spawn_fragment_parser( string $html ): ?self {
452461
return null;
453462
}
454463

455-
$fragment_processor = self::create_fragment( $html );
464+
$fragment_processor = static::create_fragment( $html );
456465

457466
$fragment_processor->change_parsing_namespace(
458467
$this->current_element->token->integration_node_type ? 'html' : $namespace

0 commit comments

Comments
 (0)