Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2874,9 +2874,6 @@ function wp_enqueue_editor_format_library_assets() {
/**
* Sanitizes an attributes array into an attributes string to be placed inside a `<script>` tag.
*
* Automatically injects type attribute if needed.
* Used by {@see wp_get_script_tag()} and {@see wp_get_inline_script_tag()}.
*
* @since 5.7.0
*
* @param array<string, string|bool> $attributes Key-value pairs representing `<script>` tag attributes.
Expand All @@ -2885,10 +2882,6 @@ function wp_enqueue_editor_format_library_assets() {
function wp_sanitize_script_attributes( $attributes ) {
$attributes_string = '';

/*
* If HTML5 script tag is supported, only the attribute name is added
* to $attributes_string for entries with a boolean value, and that are true.
*/
foreach ( $attributes as $attribute_name => $attribute_value ) {
if ( is_bool( $attribute_value ) ) {
if ( $attribute_value ) {
Expand Down
16 changes: 0 additions & 16 deletions tests/phpunit/tests/dependencies/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -1878,22 +1878,6 @@ public function test_concatenate_with_blocking_script_before_and_after_script_wi
$this->assertEqualHTML( $expected, $print_scripts, '<body>', 'Scripts are being incorrectly concatenated when a main script is registered as deferred after other blocking scripts are registered. Deferred scripts should not be part of the script concat loader query string. ' );
}

/**
* @ticket 42804
*/
public function test_wp_enqueue_script_with_html5_support_does_not_contain_type_attribute() {
global $wp_version;

$GLOBALS['wp_scripts'] = new WP_Scripts();
$GLOBALS['wp_scripts']->default_version = get_bloginfo( 'version' );

wp_enqueue_script( 'empty-deps-no-version', 'example.com' );

$expected = "<script src='http://example.com?ver={$wp_version}' id='empty-deps-no-version-js'></script>\n";

$this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) );
}

/**
* Test the different protocol references in wp_enqueue_script
*
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/tests/dependencies/wpLocalizeScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ public function test_wp_localize_script_works_before_enqueue_script() {
* @covers ::wp_localize_script
*/
public function test_wp_localize_script_outputs_safe_json() {
add_theme_support( 'html5', array( 'script' ) );

$path = '/test.js';
$base_url = site_url( $path );

Expand Down
32 changes: 0 additions & 32 deletions tests/phpunit/tests/dependencies/wpScriptTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
class Tests_Dependencies_wpScriptTag extends WP_UnitTestCase {

public function get_script_tag_type_set() {
add_theme_support( 'html5', array( 'script' ) );

$this->assertEqualHTML(
'<script src="https://localhost/PATH/FILE.js" type="application/javascript" nomodule></script>' . "\n",
wp_get_script_tag(
Expand All @@ -22,28 +20,12 @@ public function get_script_tag_type_set() {
)
)
);

remove_theme_support( 'html5' );

$this->assertEqualHTML(
'<script src="https://localhost/PATH/FILE.js" type="application/javascript" nomodule></script>' . "\n",
wp_get_script_tag(
array(
'src' => 'https://localhost/PATH/FILE.js',
'type' => 'application/javascript',
'async' => false,
'nomodule' => true,
)
)
);
}

/**
* @covers ::wp_get_script_tag
*/
public function test_get_script_tag_type_not_set() {
add_theme_support( 'html5', array( 'script' ) );

$this->assertEqualHTML(
'<script src="https://localhost/PATH/FILE.js" nomodule></script>' . "\n",
wp_get_script_tag(
Expand All @@ -54,8 +36,6 @@ public function test_get_script_tag_type_not_set() {
)
)
);

remove_theme_support( 'html5' );
}

/**
Expand All @@ -72,8 +52,6 @@ static function ( $attributes ) {
}
);

add_theme_support( 'html5', array( 'script' ) );

$attributes = array(
'src' => 'https://localhost/PATH/FILE.js',
'id' => 'utils-js-extra',
Expand All @@ -87,16 +65,6 @@ static function ( $attributes ) {
array( $attributes )
)
);

remove_theme_support( 'html5' );

$this->assertEqualHTML(
wp_get_script_tag( $attributes ),
get_echo(
'wp_print_script_tag',
array( $attributes )
)
);
}

/**
Expand Down
Loading