Make WordPress Core


Ignore:
Timestamp:
01/23/2024 05:54:25 PM (5 weeks ago)
Author:
westonruter
Message:

Script Loader: Only emit CDATA wrapper comments in wp_get_inline_script_tag() for JavaScript.

This avoids erroneously adding CDATA wrapper comments for non-JavaScript scripts, including those for JSON such as the importmap for script modules in #56313.

Props westonruter, flixos90, mukesh27, dmsnell.
See #56313.
Fixes #60320.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r57312 r57341  
    28802880     * @see https://www.w3.org/TR/xhtml1/#h-4.8
    28812881     */
    2882     if ( ! $is_html5 ) {
     2882    if (
     2883        ! $is_html5 &&
     2884        (
     2885            ! isset( $attributes['type'] ) ||
     2886            'module' === $attributes['type'] ||
     2887            str_contains( $attributes['type'], 'javascript' ) ||
     2888            str_contains( $attributes['type'], 'ecmascript' ) ||
     2889            str_contains( $attributes['type'], 'jscript' ) ||
     2890            str_contains( $attributes['type'], 'livescript' )
     2891        )
     2892    ) {
    28832893        /*
    28842894         * If the string `]]>` exists within the JavaScript it would break
Note: See TracChangeset for help on using the changeset viewer.