Skip to content

Commit f48ccef

Browse files
committed
Fix test compat with WP 6.6
1 parent 90ca45a commit f48ccef

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

plugins/web-worker-offloading/tests/test-web-worker-offloading.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,16 @@ public function test_update_script_types( Closure $set_up, string $expected ): v
208208

209209
$normalize = static function ( $html ) {
210210
// See <https://core.trac.wordpress.org/ticket/63887>.
211-
$p = new WP_HTML_Tag_Processor( $html );
212-
while ( $p->next_tag( array( 'tag_name' => 'SCRIPT' ) ) ) {
213-
$text = $p->get_modifiable_text();
214-
$text = preg_replace( ':\n//# sourceURL=.+$:', '', $text );
215-
$p->set_modifiable_text( $text );
211+
if ( class_exists( 'WP_HTML_Tag_Processor' ) ) {
212+
// This normalization logic is only relevant to WP>=6.9-alpha anyway.
213+
$p = new WP_HTML_Tag_Processor( $html );
214+
while ( $p->next_tag( array( 'tag_name' => 'SCRIPT' ) ) ) {
215+
$text = $p->get_modifiable_text();
216+
$text = preg_replace( ':\n//# sourceURL=.+$:', '', $text );
217+
$p->set_modifiable_text( $text );
218+
}
219+
$html = $p->get_updated_html();
216220
}
217-
$html = $p->get_updated_html();
218221

219222
$html = preg_replace( '/\r|\n/', '', $html );
220223
return trim( preg_replace( '#(?=<[^/])#', "\n", $html ) );

0 commit comments

Comments
 (0)