mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-31 14:10:28 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@57341 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2879,7 +2879,17 @@ function wp_get_inline_script_tag( $javascript, $attributes = array() ) {
|
||||
*
|
||||
* @see https://www.w3.org/TR/xhtml1/#h-4.8
|
||||
*/
|
||||
if ( ! $is_html5 ) {
|
||||
if (
|
||||
! $is_html5 &&
|
||||
(
|
||||
! isset( $attributes['type'] ) ||
|
||||
'module' === $attributes['type'] ||
|
||||
str_contains( $attributes['type'], 'javascript' ) ||
|
||||
str_contains( $attributes['type'], 'ecmascript' ) ||
|
||||
str_contains( $attributes['type'], 'jscript' ) ||
|
||||
str_contains( $attributes['type'], 'livescript' )
|
||||
)
|
||||
) {
|
||||
/*
|
||||
* If the string `]]>` exists within the JavaScript it would break
|
||||
* out of any wrapping CDATA section added here, so to start, it's
|
||||
|
||||
Reference in New Issue
Block a user