Skip to content

Commit b15189f

Browse files
committed
Merge branch 'main' into add-selector-support
2 parents 850ba28 + 2769d75 commit b15189f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

html-api-debugger/html-api-integration.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ function get_supports(): array {
2323
* @return string|null The normalized HTML or null if not supported.
2424
*/
2525
function get_normalized_html( string $html, array $options ): ?string {
26+
$cfacn = new ReflectionMethod( WP_HTML_Processor::class, 'create_fragment_at_current_node' );
27+
$cfacn->setAccessible( true );
28+
2629
if (
2730
method_exists( WP_HTML_Processor::class, 'create_fragment_at_current_node' ) &&
2831
$options['context_html']
@@ -40,7 +43,7 @@ function get_normalized_html( string $html, array $options ): ?string {
4043
* @var WP_HTML_Processor|null $processor
4144
* @disregard P1013
4245
*/
43-
$processor = $context_processor->create_fragment_at_current_node( $html );
46+
$processor = $cfacn->invoke( $context_processor, $html );
4447
}
4548
} else {
4649
$processor = WP_HTML_Processor::create_full_parser( $html );
@@ -78,6 +81,9 @@ function get_tree( string $html, array $options ): array {
7881
$processor_bookmarks = new ReflectionProperty( WP_HTML_Processor::class, 'bookmarks' );
7982
$processor_bookmarks->setAccessible( true );
8083

84+
$cfacn = new ReflectionMethod( WP_HTML_Processor::class, 'create_fragment_at_current_node' );
85+
$cfacn->setAccessible( true );
86+
8187
$is_fragment_processor = false;
8288

8389
$compat_mode = 'BackCompat';
@@ -126,7 +132,7 @@ function get_tree( string $html, array $options ): array {
126132
* @var WP_HTML_Processor|null $processor
127133
* @disregard P1013
128134
*/
129-
$processor = $context_processor->create_fragment_at_current_node( $html );
135+
$processor = $cfacn->invoke( $context_processor, $html );
130136
}
131137

132138
if ( ! isset( $processor ) ) {

0 commit comments

Comments
 (0)