<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[56687] trunk: Script Loader: Use `wp_get_script_tag()` and `wp_get_inline_script_tag()`/`wp_print_inline_script_tag()` helper functions to output scripts on the frontend and login screen.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/56687">56687</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/56687","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>westonruter</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2023-09-25 21:03:19 +0000 (Mon, 25 Sep 2023)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Script Loader: Use `wp_get_script_tag()` and `wp_get_inline_script_tag()`/`wp_print_inline_script_tag()` helper functions to output scripts on the frontend and login screen.
Using script tag helper functions allows plugins to employ the `wp_script_attributes` and `wp_inline_script_attributes` filters to inject the `nonce` attribute to apply Content Security Policy (e.g. Strict CSP). Use of helper functions also simplifies logic in `WP_Scripts`.
* Update `wp_get_inline_script_tag()` to wrap inline script in CDATA blocks for XHTML-compatibility when not using HTML5.
* Ensure the `type` attribute is printed first in `wp_get_inline_script_tag()` for back-compat.
* Wrap existing `<script>` tags in output buffering to retain IDE supports.
* In `wp_get_inline_script_tag()`, append the newline to `$javascript` before it is passed into the `wp_inline_script_attributes` filter so that the CSP hash can be computed properly.
* In `the_block_template_skip_link()`, opt to enqueue the inline script rather than print it.
* Add `ext-php` to `composer.json` under `suggest` as previously it was an undeclared dependency for running PHPUnit tests.
* Update tests to rely on `DOMDocument` to compare script markup, normalizing unsemantic differences.
Props westonruter, spacedmonkey, flixos90, 10upsimon, dmsnell, mukesh27, joemcgill, swissspidy, azaozz.
Fixes <a href="https://core.trac.wordpress.org/ticket/58664">#58664</a>.
See <a href="https://core.trac.wordpress.org/ticket/39941">#39941</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkcomposerjson">trunk/composer.json</a></li>
<li><a href="#trunksrcwpincludesclasswpcustomizemanagerphp">trunk/src/wp-includes/class-wp-customize-manager.php</a></li>
<li><a href="#trunksrcwpincludesclasswpcustomizenavmenusphp">trunk/src/wp-includes/class-wp-customize-nav-menus.php</a></li>
<li><a href="#trunksrcwpincludesclasswpcustomizewidgetsphp">trunk/src/wp-includes/class-wp-customize-widgets.php</a></li>
<li><a href="#trunksrcwpincludesclasswpscriptsphp">trunk/src/wp-includes/class-wp-scripts.php</a></li>
<li><a href="#trunksrcwpincludescommenttemplatephp">trunk/src/wp-includes/comment-template.php</a></li>
<li><a href="#trunksrcwpincludescustomizeclasswpcustomizeselectiverefreshphp">trunk/src/wp-includes/customize/class-wp-customize-selective-refresh.php</a></li>
<li><a href="#trunksrcwpincludesfunctionsphp">trunk/src/wp-includes/functions.php</a></li>
<li><a href="#trunksrcwpincludesscriptloaderphp">trunk/src/wp-includes/script-loader.php</a></li>
<li><a href="#trunksrcwpincludesthemetemplatesphp">trunk/src/wp-includes/theme-templates.php</a></li>
<li><a href="#trunksrcwpincludesthemephp">trunk/src/wp-includes/theme.php</a></li>
<li><a href="#trunksrcwpincludeswidgetsclasswpwidgetarchivesphp">trunk/src/wp-includes/widgets/class-wp-widget-archives.php</a></li>
<li><a href="#trunksrcwpincludeswidgetsclasswpwidgetcategoriesphp">trunk/src/wp-includes/widgets/class-wp-widget-categories.php</a></li>
<li><a href="#trunksrcwploginphp">trunk/src/wp-login.php</a></li>
<li><a href="#trunktestsphpunittestscustomizemanagerphp">trunk/tests/phpunit/tests/customize/manager.php</a></li>
<li><a href="#trunktestsphpunittestsdependenciesscriptsphp">trunk/tests/phpunit/tests/dependencies/scripts.php</a></li>
<li><a href="#trunktestsphpunittestsdependencieswpInlineScriptTagphp">trunk/tests/phpunit/tests/dependencies/wpInlineScriptTag.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkcomposerjson"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/composer.json</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/composer.json 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/composer.json 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -12,6 +12,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> "require": {
</span><span class="cx" style="display: block; padding: 0 10px"> "php": ">=7.0"
</span><span class="cx" style="display: block; padding: 0 10px"> },
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ "suggest": {
+ "ext-dom": "*"
+ },
</ins><span class="cx" style="display: block; padding: 0 10px"> "require-dev": {
</span><span class="cx" style="display: block; padding: 0 10px"> "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
</span><span class="cx" style="display: block; padding: 0 10px"> "squizlabs/php_codesniffer": "3.6.0",
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpcustomizemanagerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-customize-manager.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-customize-manager.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/src/wp-includes/class-wp-customize-manager.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -464,6 +464,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> 'error' => $ajax_message,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $message .= ob_get_clean();
+ ob_start();
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <script>
</span><span class="cx" style="display: block; padding: 0 10px"> ( function( api, settings ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -472,7 +474,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } )( wp.customize, <?php echo wp_json_encode( $settings ); ?> );
</span><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $message .= ob_get_clean();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $message .= wp_get_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_die( $message );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2083,6 +2085,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $this->messenger_channel ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ob_start();
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <script>
</span><span class="cx" style="display: block; padding: 0 10px"> ( function() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2106,6 +2109,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> } )();
</span><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2201,8 +2205,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ob_start();
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <script type="text/javascript">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script>
</ins><span class="cx" style="display: block; padding: 0 10px"> var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>;
</span><span class="cx" style="display: block; padding: 0 10px"> _wpCustomizeSettings.values = {};
</span><span class="cx" style="display: block; padding: 0 10px"> (function( v ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2225,6 +2230,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> })( _wpCustomizeSettings.values );
</span><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4976,8 +4982,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ob_start();
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <script type="text/javascript">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script>
</ins><span class="cx" style="display: block; padding: 0 10px"> var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>;
</span><span class="cx" style="display: block; padding: 0 10px"> _wpCustomizeSettings.initialClientTimestamp = _.now();
</span><span class="cx" style="display: block; padding: 0 10px"> _wpCustomizeSettings.controls = {};
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5012,6 +5019,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpcustomizenavmenusphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-customize-nav-menus.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-customize-nav-menus.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/src/wp-includes/class-wp-customize-nav-menus.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1559,7 +1559,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $exports = array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'navMenuInstanceArgs' => $this->preview_nav_menu_instance_args,
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( '<script>var _wpCustomizePreviewNavMenusExports = %s;</script>', wp_json_encode( $exports ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( sprintf( 'var _wpCustomizePreviewNavMenusExports = %s;', wp_json_encode( $exports ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpcustomizewidgetsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-customize-widgets.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-customize-widgets.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/src/wp-includes/class-wp-customize-widgets.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1310,12 +1310,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $settings['registeredWidgets'] as &$registered_widget ) {
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $registered_widget['callback'] ); // May not be JSON-serializeable.
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- ?>
- <script type="text/javascript">
- var _wpWidgetCustomizerPreviewSettings = <?php echo wp_json_encode( $settings ); ?>;
- </script>
- <?php
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag(
+ sprintf( 'var _wpWidgetCustomizerPreviewSettings = %s;', wp_json_encode( $settings ) )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpscriptsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-scripts.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-scripts.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/src/wp-includes/class-wp-scripts.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -123,17 +123,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public $default_dirs;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Holds a string which contains the type attribute for script tag.
- *
- * If the active theme does not declare HTML5 support for 'script',
- * then it initializes as `type='text/javascript'`.
- *
- * @since 5.3.0
- * @var string
- */
- private $type_attr = '';
-
- /**
</del><span class="cx" style="display: block; padding: 0 10px"> * Holds a mapping of dependents (as handles) for a given script handle.
</span><span class="cx" style="display: block; padding: 0 10px"> * Used to optimize recursive dependency tree checks.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -167,14 +156,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.4.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function init() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if (
- function_exists( 'is_admin' ) && ! is_admin()
- &&
- function_exists( 'current_theme_supports' ) && ! current_theme_supports( 'html5', 'script' )
- ) {
- $this->type_attr = " type='text/javascript'";
- }
-
</del><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Fires when the WP_Scripts instance is initialized.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -245,21 +226,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $output;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( "<script%s id='%s-js-extra'>\n", $this->type_attr, esc_attr( $handle ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( $output, array( 'id' => "{$handle}-js-extra" ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // CDATA is not needed for HTML 5.
- if ( $this->type_attr ) {
- echo "/* <![CDATA[ */\n";
- }
-
- echo "$output\n";
-
- if ( $this->type_attr ) {
- echo "/* ]]> */\n";
- }
-
- echo "</script>\n";
-
</del><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -335,7 +303,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $translations = $this->print_translations( $handle, false );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $translations ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $translations = sprintf( "<script%s id='%s-js-translations'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), $translations );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $translations = wp_get_inline_script_tag( $translations, array( 'id' => "{$handle}-js-translations" ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->do_concat ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -403,21 +371,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /** This filter is documented in wp-includes/class-wp-scripts.php */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $src = esc_url_raw( apply_filters( 'script_loader_src', $src, $handle ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $src ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attr = array(
+ 'src' => $src,
+ 'id' => "{$handle}-js",
+ );
+ if ( $strategy ) {
+ $attr[ $strategy ] = true;
+ }
+ if ( $intended_strategy ) {
+ $attr['data-wp-strategy'] = $intended_strategy;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> $tag = $translations . $cond_before . $before_script;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tag .= sprintf(
- "<script%s src='%s' id='%s-js'%s%s></script>\n",
- $this->type_attr,
- $src, // Value is escaped above.
- esc_attr( $handle ),
- $strategy ? " {$strategy}" : '',
- $intended_strategy ? " data-wp-strategy='{$intended_strategy}'" : ''
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $tag .= wp_get_script_tag( $attr );
</ins><span class="cx" style="display: block; padding: 0 10px"> $tag .= $after_script . $cond_after;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -720,7 +691,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> JS;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $display ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( "<script%s id='%s-js-translations'>\n%s\n</script>\n", $this->type_attr, esc_attr( $handle ), $output );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( $output, array( 'id' => "{$handle}-js-translations" ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $output;
</span></span></pre></div>
<a id="trunksrcwpincludescommenttemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/comment-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/comment-template.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/src/wp-includes/comment-template.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1366,7 +1366,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( current_user_can( 'unfiltered_html' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- echo "<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( "(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();" );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludescustomizeclasswpcustomizeselectiverefreshphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/customize/class-wp-customize-selective-refresh.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/customize/class-wp-customize-selective-refresh.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/src/wp-includes/customize/class-wp-customize-selective-refresh.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -193,7 +193,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Export data to JS.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- printf( '<script>var _customizePartialRefreshExports = %s;</script>', wp_json_encode( $exports ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( sprintf( 'var _customizePartialRefreshExports = %s;', wp_json_encode( $exports ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/functions.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/src/wp-includes/functions.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7655,6 +7655,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Has to match the window name used in post_submit_meta_box().
</span><span class="cx" style="display: block; padding: 0 10px"> $name = 'wp-preview-' . (int) $post->ID;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ob_start();
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <script>
</span><span class="cx" style="display: block; padding: 0 10px"> ( function() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7670,6 +7671,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }());
</span><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesscriptloaderphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/script-loader.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/script-loader.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/src/wp-includes/script-loader.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2787,7 +2787,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_get_script_tag( $attributes ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! isset( $attributes['type'] ) && ! is_admin() && ! current_theme_supports( 'html5', 'script' ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attributes['type'] = 'text/javascript';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Keep the type attribute as the first for legacy reasons (it has always been this way in core).
+ $attributes = array_merge(
+ array( 'type' => 'text/javascript' ),
+ $attributes
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters attributes to be added to a script tag.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2830,9 +2834,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @return string String containing inline JavaScript code wrapped around `<script>` tag.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_get_inline_script_tag( $javascript, $attributes = array() ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! isset( $attributes['type'] ) && ! is_admin() && ! current_theme_supports( 'html5', 'script' ) ) {
- $attributes['type'] = 'text/javascript';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $is_html5 = current_theme_supports( 'html5', 'script' ) || is_admin();
+ if ( ! isset( $attributes['type'] ) && ! $is_html5 ) {
+ // Keep the type attribute as the first for legacy reasons (it has always been this way in core).
+ $attributes = array_merge(
+ array( 'type' => 'text/javascript' ),
+ $attributes
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ // Ensure markup is XHTML compatible if not HTML5.
+ if ( ! $is_html5 ) {
+ $javascript = str_replace( ']]>', ']]]]><![CDATA[>', $javascript ); // Escape any existing CDATA section.
+ $javascript = sprintf( "/* <![CDATA[ */\n%s\n/* ]]> */", $javascript );
+ }
+
+ $javascript = "\n" . trim( $javascript, "\n\r " ) . "\n";
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filters attributes to be added to a script tag.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2845,8 +2863,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $attributes = apply_filters( 'wp_inline_script_attributes', $attributes, $javascript );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $javascript = "\n" . trim( $javascript, "\n\r " ) . "\n";
-
</del><span class="cx" style="display: block; padding: 0 10px"> return sprintf( "<script%s>%s</script>\n", wp_sanitize_script_attributes( $attributes ), $javascript );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludesthemetemplatesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/theme-templates.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/theme-templates.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/src/wp-includes/theme-templates.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -160,8 +160,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_style( $handle );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Print the skip-link script.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Enqueue the skip-link script.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ob_start();
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <script>
</span><span class="cx" style="display: block; padding: 0 10px"> ( function() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -204,6 +205,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }() );
</span><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $skip_link_script = str_replace( array( '<script>', '</script>' ), '', ob_get_clean() );
+ $script_handle = 'wp-block-template-skip-link';
+ wp_register_script( $script_handle, false );
+ wp_add_inline_script( $script_handle, $skip_link_script );
+ wp_enqueue_script( $script_handle );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludesthemephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/theme.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/theme.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/src/wp-includes/theme.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3783,9 +3783,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $admin_origin = parse_url( admin_url() );
</span><span class="cx" style="display: block; padding: 0 10px"> $home_origin = parse_url( home_url() );
</span><span class="cx" style="display: block; padding: 0 10px"> $cross_domain = ( strtolower( $admin_origin['host'] ) !== strtolower( $home_origin['host'] ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ob_start();
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <script<?php echo $type_attr; ?>>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script>
</ins><span class="cx" style="display: block; padding: 0 10px"> (function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var request, b = document.body, c = 'className', cs = 'customize-support', rcs = new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)');
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3801,6 +3801,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }());
</span><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunksrcwpincludeswidgetsclasswpwidgetarchivesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/widgets/class-wp-widget-archives.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/widgets/class-wp-widget-archives.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/src/wp-includes/widgets/class-wp-widget-archives.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -100,8 +100,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $label = __( 'Select Post' );
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
- $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"';
</del><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <option value=""><?php echo esc_html( $label ); ?></option>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -109,8 +107,8 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> </select>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<script<?php echo $type_attr; ?>>
-/* <![CDATA[ */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <?php ob_start(); ?>
+<script>
</ins><span class="cx" style="display: block; padding: 0 10px"> (function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" );
</span><span class="cx" style="display: block; padding: 0 10px"> function onSelectChange() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -120,9 +118,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> dropdown.onchange = onSelectChange;
</span><span class="cx" style="display: block; padding: 0 10px"> })();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/* ]]> */
</del><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml';
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwpincludeswidgetsclasswpwidgetcategoriesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/widgets/class-wp-widget-categories.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/widgets/class-wp-widget-categories.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/src/wp-includes/widgets/class-wp-widget-categories.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -92,11 +92,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> echo '</form>';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $type_attr = current_theme_supports( 'html5', 'script' ) ? '' : ' type="text/javascript"';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ob_start();
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<script<?php echo $type_attr; ?>>
-/* <![CDATA[ */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<script>
</ins><span class="cx" style="display: block; padding: 0 10px"> (function() {
</span><span class="cx" style="display: block; padding: 0 10px"> var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" );
</span><span class="cx" style="display: block; padding: 0 10px"> function onCatChange() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -106,10 +105,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> dropdown.onchange = onCatChange;
</span><span class="cx" style="display: block; padding: 0 10px"> })();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-/* ]]> */
</del><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml';
</span><span class="cx" style="display: block; padding: 0 10px">
</span></span></pre></div>
<a id="trunksrcwploginphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-login.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-login.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/src/wp-login.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -101,9 +101,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * but maybe better if it's not removable by plugins.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'loggedout' === $wp_error->get_error_code() ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ob_start();
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> <script>if("sessionStorage" in window){try{for(var key in sessionStorage){if(key.indexOf("wp-autosave-")!=-1){sessionStorage.removeItem(key)}}}catch(e){}};</script>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -193,10 +195,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="cx" style="display: block; padding: 0 10px"> </head>
</span><span class="cx" style="display: block; padding: 0 10px"> <body class="login no-js <?php echo esc_attr( implode( ' ', $classes ) ); ?>">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <script type="text/javascript">
- document.body.className = document.body.className.replace('no-js','js');
- </script>
</del><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( "document.body.className = document.body.className.replace('no-js','js');" );
+ ?>
+
+ <?php
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Fires in the login page header after the body tag is opened.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -414,12 +417,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $input_id ) ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ob_start();
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <script type="text/javascript">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script>
</ins><span class="cx" style="display: block; padding: 0 10px"> try{document.getElementById('<?php echo $input_id; ?>').focus();}catch(e){}
</span><span class="cx" style="display: block; padding: 0 10px"> if(typeof wpOnload==='function')wpOnload();
</span><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -441,11 +446,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.0.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function wp_shake_js() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ?>
- <script type="text/javascript">
- document.querySelector('form').classList.add('shake');
- </script>
- <?php
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( "document.querySelector('form').classList.add('shake');" );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1357,9 +1358,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> do_action( 'login_footer' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $customize_login ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ob_start();
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script>
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script>setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script>
</ins><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1605,15 +1608,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Run `wpOnload()` if defined.
</span><span class="cx" style="display: block; padding: 0 10px"> $login_script .= "if ( typeof wpOnload === 'function' ) { wpOnload() }";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ?>
- <script type="text/javascript">
- <?php echo $login_script; ?>
- </script>
- <?php
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( $login_script );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $interim_login ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ob_start();
</ins><span class="cx" style="display: block; padding: 0 10px"> ?>
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- <script type="text/javascript">
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ <script>
</ins><span class="cx" style="display: block; padding: 0 10px"> ( function() {
</span><span class="cx" style="display: block; padding: 0 10px"> try {
</span><span class="cx" style="display: block; padding: 0 10px"> var i, links = document.getElementsByTagName( 'a' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1627,6 +1627,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }());
</span><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> <?php
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_print_inline_script_tag( str_replace( array( '<script>', '</script>' ), '', ob_get_clean() ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> login_footer();
</span></span></pre></div>
<a id="trunktestsphpunittestscustomizemanagerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/customize/manager.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/customize/manager.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/tests/phpunit/tests/customize/manager.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3136,7 +3136,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ob_start();
</span><span class="cx" style="display: block; padding: 0 10px"> $manager->remove_frameless_preview_messenger_channel();
</span><span class="cx" style="display: block; padding: 0 10px"> $output = ob_get_clean();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertStringContainsString( '<script>', $output );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertStringContainsString( '<script', $output );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestsdependenciesscriptsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/dependencies/scripts.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/dependencies/scripts.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/tests/phpunit/tests/dependencies/scripts.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -42,11 +42,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->wp_scripts_print_translations_output = <<<JS
</span><span class="cx" style="display: block; padding: 0 10px"> <script type='text/javascript' id='__HANDLE__-js-translations'>
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* <![CDATA[ */
</ins><span class="cx" style="display: block; padding: 0 10px"> ( function( domain, translations ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var localeData = translations.locale_data[ domain ] || translations.locale_data.messages;
</span><span class="cx" style="display: block; padding: 0 10px"> localeData[""].domain = domain;
</span><span class="cx" style="display: block; padding: 0 10px"> wp.i18n.setLocaleData( localeData, domain );
</span><span class="cx" style="display: block; padding: 0 10px"> } )( "__DOMAIN__", __JSON_TRANSLATIONS__ );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* ]]> */
</ins><span class="cx" style="display: block; padding: 0 10px"> </script>
</span><span class="cx" style="display: block; padding: 0 10px"> JS;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->wp_scripts_print_translations_output .= "\n";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -77,7 +79,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='http://example.com?ver=1.2' id='empty-deps-version-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='http://example.com' id='empty-deps-null-version-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // No scripts left to print.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '', get_echo( 'wp_print_scripts' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -118,12 +120,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $output = get_echo( 'wp_print_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='http://example.org/ms-isa-1.js' id='ms-isa-1-js' data-wp-strategy='{$strategy}'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= wp_get_inline_script_tag(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "console.log(\"after one\");\n",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'console.log("after one");',
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'id' => 'ms-isa-1-js-after',
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $output, 'Inline scripts in the "after" position, that are attached to a deferred main script, are failing to print/execute.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, $output, 'Inline scripts in the "after" position, that are attached to a deferred main script, are failing to print/execute.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -146,13 +148,13 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='http://example.org/ms-insa-3.js' id='ms-insa-3-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= wp_get_inline_script_tag(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "console.log(\"after one\");\n",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'console.log("after one");',
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'id' => 'ms-insa-3-js-after',
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $output, 'Inline scripts in the "after" position, that are attached to a blocking main script, are failing to print/execute.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, $output, 'Inline scripts in the "after" position, that are attached to a blocking main script, are failing to print/execute.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -180,7 +182,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $output = get_echo( 'wp_print_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = wp_get_inline_script_tag(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "console.log(\"before first\");\n",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'console.log("before first");',
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'id' => 'ds-i1-1-js-before',
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -189,7 +191,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='http://example.org/ds-i1-2.js' id='ds-i1-2-js' $strategy data-wp-strategy='{$strategy}'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='http://example.org/ds-i1-3.js' id='ds-i1-3-js' $strategy data-wp-strategy='{$strategy}'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= wp_get_inline_script_tag(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- "console.log(\"before last\");\n",
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'console.log("before last");',
</ins><span class="cx" style="display: block; padding: 0 10px"> array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'id' => 'ms-i1-1-js-before',
</span><span class="cx" style="display: block; padding: 0 10px"> 'type' => 'text/javascript',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -197,7 +199,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='http://example.org/ms-i1-1.js' id='ms-i1-1-js' {$strategy} data-wp-strategy='{$strategy}'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $output, 'Inline scripts in the "before" position, that are attached to a deferred main script, are failing to print/execute.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, $output, 'Inline scripts in the "before" position, that are attached to a deferred main script, are failing to print/execute.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -215,7 +217,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'main-script-a1', '/main-script-a1.js', array(), null, array( 'strategy' => 'async' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $output = get_echo( 'wp_print_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='/main-script-a1.js' id='main-script-a1-js' async data-wp-strategy='async'></script>\n";
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $output, 'Scripts enqueued with an async loading strategy are failing to have the async attribute applied to the script handle when being printed.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, $output, 'Scripts enqueued with an async loading strategy are failing to have the async attribute applied to the script handle when being printed.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -235,9 +237,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_delayed_dependent_with_blocking_dependency( $strategy ) {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'dependency-script-a2', '/dependency-script-a2.js', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'main-script-a2', '/main-script-a2.js', array( 'dependency-script-a2' ), null, compact( 'strategy' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $output = get_echo( 'wp_print_scripts' );
- $expected = "<script type='text/javascript' src='/main-script-a2.js' id='main-script-a2-js' {$strategy} data-wp-strategy='{$strategy}'></script>";
- $this->assertStringContainsString( $expected, $output, 'Dependents of a blocking dependency are free to have any strategy.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $output = get_echo( 'wp_print_scripts' );
+ $expected = "<script id='dependency-script-a2-js' src='/dependency-script-a2.js'></script>\n";
+ $expected .= "<script type='text/javascript' src='/main-script-a2.js' id='main-script-a2-js' {$strategy} data-wp-strategy='{$strategy}'></script>";
+ $this->assertEqualMarkup( $expected, $output, 'Dependents of a blocking dependency are free to have any strategy.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -257,7 +260,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'main-script-a3', '/main-script-a3.js', array(), null, compact( 'strategy' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'dependent-script-a3', '/dependent-script-a3.js', array( 'main-script-a3' ), null );
</span><span class="cx" style="display: block; padding: 0 10px"> $output = get_echo( 'wp_print_scripts' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='/main-script-a3.js' id='main-script-a3-js' data-wp-strategy='{$strategy}'></script>";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = str_replace( "'", '"', "<script type='text/javascript' src='/main-script-a3.js' id='main-script-a3-js' data-wp-strategy='{$strategy}'></script>" );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringContainsString( $expected, $output, 'Blocking dependents must force delayed dependencies to become blocking.' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -275,11 +278,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $strategy Strategy.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_delayed_dependent_with_blocking_dependency_not_enqueued( $strategy ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->add_html5_script_theme_support();
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'main-script-a4', '/main-script-a4.js', array(), null, compact( 'strategy' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> // This dependent is registered but not enqueued, so it should not factor into the eligible loading strategy.
</span><span class="cx" style="display: block; padding: 0 10px"> wp_register_script( 'dependent-script-a4', '/dependent-script-a4.js', array( 'main-script-a4' ), null );
</span><span class="cx" style="display: block; padding: 0 10px"> $output = get_echo( 'wp_print_scripts' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='/main-script-a4.js' id='main-script-a4-js' {$strategy} data-wp-strategy='{$strategy}'></script>";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = str_replace( "'", '"', "<script src='/main-script-a4.js' id='main-script-a4-js' {$strategy} data-wp-strategy='{$strategy}'></script>" );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringContainsString( $expected, $output, 'Only enqueued dependents should affect the eligible strategy.' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -964,9 +968,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::wp_enqueue_script
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_loading_strategy_with_defer_having_no_dependents_nor_dependencies() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->add_html5_script_theme_support();
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'main-script-d1', 'http://example.com/main-script-d1.js', array(), null, array( 'strategy' => 'defer' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $output = get_echo( 'wp_print_scripts' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='http://example.com/main-script-d1.js' id='main-script-d1-js' defer data-wp-strategy='defer'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = str_replace( "'", '"', "<script src='http://example.com/main-script-d1.js' id='main-script-d1-js' defer data-wp-strategy='defer'></script>\n" );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringContainsString( $expected, $output, 'Expected defer, as there is no dependent or dependency' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -980,12 +985,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::wp_enqueue_script
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_loading_strategy_with_defer_dependent_and_varied_dependencies() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->add_html5_script_theme_support();
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'dependency-script-d2-1', 'http://example.com/dependency-script-d2-1.js', array(), null, array( 'strategy' => 'defer' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'dependency-script-d2-2', 'http://example.com/dependency-script-d2-2.js', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'dependency-script-d2-3', 'http://example.com/dependency-script-d2-3.js', array( 'dependency-script-d2-2' ), null, array( 'strategy' => 'defer' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'main-script-d2', 'http://example.com/main-script-d2.js', array( 'dependency-script-d2-1', 'dependency-script-d2-3' ), null, array( 'strategy' => 'defer' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $output = get_echo( 'wp_print_scripts' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='http://example.com/main-script-d2.js' id='main-script-d2-js' defer data-wp-strategy='defer'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = '<script src="http://example.com/main-script-d2.js" id="main-script-d2-js" defer data-wp-strategy="defer"></script>';
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringContainsString( $expected, $output, 'Expected defer, as all dependencies are either deferred or blocking' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -999,12 +1005,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @covers ::wp_enqueue_script
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_loading_strategy_with_all_defer_dependencies() {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->add_html5_script_theme_support();
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'main-script-d3', 'http://example.com/main-script-d3.js', array(), null, array( 'strategy' => 'defer' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'dependent-script-d3-1', 'http://example.com/dependent-script-d3-1.js', array( 'main-script-d3' ), null, array( 'strategy' => 'defer' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'dependent-script-d3-2', 'http://example.com/dependent-script-d3-2.js', array( 'dependent-script-d3-1' ), null, array( 'strategy' => 'defer' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'dependent-script-d3-3', 'http://example.com/dependent-script-d3-3.js', array( 'dependent-script-d3-2' ), null, array( 'strategy' => 'defer' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $output = get_echo( 'wp_print_scripts' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='http://example.com/main-script-d3.js' id='main-script-d3-js' defer data-wp-strategy='defer'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = '<script src="http://example.com/main-script-d3.js" id="main-script-d3-js" defer data-wp-strategy="defer"></script>';
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringContainsString( $expected, $output, 'Expected defer, as all dependents have defer loading strategy' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1029,7 +1036,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/dependent-script-d4-2.js' id='dependent-script-d4-2-js' defer data-wp-strategy='async'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/dependent-script-d4-3.js' id='dependent-script-d4-3-js' defer data-wp-strategy='defer'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $output, 'Scripts registered as defer but that have dependents that are async are expected to have said dependents deferred.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, $output, 'Scripts registered as defer but that have dependents that are async are expected to have said dependents deferred.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1049,7 +1056,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'dependent-script-d4-2', '/dependent-script-d4-2.js', array( 'dependent-script-d4-1' ), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'dependent-script-d4-3', '/dependent-script-d4-3.js', array( 'dependent-script-d4-2' ), null, array( 'strategy' => 'defer' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $output = get_echo( 'wp_print_scripts' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = "<script type='text/javascript' src='/main-script-d4.js' id='main-script-d4-js' data-wp-strategy='defer'></script>\n";
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = str_replace( "'", '"', "<script type='text/javascript' src='/main-script-d4.js' id='main-script-d4-js' data-wp-strategy='defer'></script>\n" );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringContainsString( $expected, $output, 'Scripts registered as defer but that have all dependents with no strategy, should become blocking (no strategy).' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1067,6 +1074,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'main-script-b1', '/main-script-b1.js', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> $output = get_echo( 'wp_print_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='/main-script-b1.js' id='main-script-b1-js'></script>\n";
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = str_replace( "'", '"', $expected );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $expected, $output, 'Scripts registered with a "blocking" strategy, and who have no dependencies, should have no loading strategy attributes printed.' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // strategy args not set.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1073,6 +1081,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'main-script-b2', '/main-script-b2.js', array(), null, array() );
</span><span class="cx" style="display: block; padding: 0 10px"> $output = get_echo( 'wp_print_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='/main-script-b2.js' id='main-script-b2-js'></script>\n";
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = str_replace( "'", '"', $expected );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $expected, $output, 'Scripts registered with no strategy assigned, and who have no dependencies, should have no loading strategy attributes printed.' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1099,7 +1108,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_header .= "<script type='text/javascript' src='/enqueue-header-old.js' id='enqueue-header-old-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_header .= "<script type='text/javascript' src='/enqueue-header-new.js' id='enqueue-header-new-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected_header, $actual_header, 'Scripts registered/enqueued using the older $in_footer parameter or the newer $args parameter should have the same outcome.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected_header, $actual_header, 'Scripts registered/enqueued using the older $in_footer parameter or the newer $args parameter should have the same outcome.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( $actual_footer, 'Expected footer to be empty since all scripts were for head.' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1127,7 +1136,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_footer .= "<script type='text/javascript' src='/enqueue-footer-new.js' id='enqueue-footer-new-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEmpty( $actual_header, 'Expected header to be empty since all scripts targeted footer.' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected_footer, $actual_footer, 'Scripts registered/enqueued using the older $in_footer parameter or the newer $args parameter should have the same outcome.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected_footer, $actual_footer, 'Scripts registered/enqueued using the older $in_footer parameter or the newer $args parameter should have the same outcome.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1246,7 +1255,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_register_script( 'invalid-strategy', '/defaults.js', array(), null, array( 'strategy' => 'random-strategy' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'invalid-strategy' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup(
</ins><span class="cx" style="display: block; padding: 0 10px"> "<script type='text/javascript' src='/defaults.js' id='invalid-strategy-js'></script>\n",
</span><span class="cx" style="display: block; padding: 0 10px"> get_echo( 'wp_print_scripts' )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1271,7 +1280,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_script_add_data( 'invalid-strategy', 'strategy', 'random-strategy' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'invalid-strategy' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup(
</ins><span class="cx" style="display: block; padding: 0 10px"> "<script type='text/javascript' src='/defaults.js' id='invalid-strategy-js'></script>\n",
</span><span class="cx" style="display: block; padding: 0 10px"> get_echo( 'wp_print_scripts' )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1292,7 +1301,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_script_strategy_doing_it_wrong_via_enqueue() {
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'invalid-strategy', '/defaults.js', array(), null, array( 'strategy' => 'random-strategy' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup(
</ins><span class="cx" style="display: block; padding: 0 10px"> "<script type='text/javascript' src='/defaults.js' id='invalid-strategy-js'></script>\n",
</span><span class="cx" style="display: block; padding: 0 10px"> get_echo( 'wp_print_scripts' )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1330,7 +1339,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=one-concat-dep,two-concat-dep,three-concat-dep&ver={$wp_version}'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/main-script.js' id='main-defer-script-js' defer data-wp-strategy='defer'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $print_scripts, 'Scripts are being incorrectly concatenated when a main script is registered with a "defer" loading strategy. Deferred scripts should not be part of the script concat loading query.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, $print_scripts, 'Scripts are being incorrectly concatenated when a main script is registered with a "defer" loading strategy. Deferred scripts should not be part of the script concat loading query.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1365,7 +1374,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=one-concat-dep-1,two-concat-dep-1,three-concat-dep-1&ver={$wp_version}'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/main-script.js' id='main-async-script-1-js' async data-wp-strategy='async'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $print_scripts, 'Scripts are being incorrectly concatenated when a main script is registered with an "async" loading strategy. Async scripts should not be part of the script concat loading query.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, $print_scripts, 'Scripts are being incorrectly concatenated when a main script is registered with an "async" loading strategy. Async scripts should not be part of the script concat loading query.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1404,7 +1413,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=one-concat-dep-2,two-concat-dep-2,three-concat-dep-2,four-concat-dep-2,five-concat-dep-2,six-concat-dep-2&ver={$wp_version}'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/main-script.js' id='deferred-script-2-js' defer data-wp-strategy='defer'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $print_scripts, '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. ' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, $print_scripts, '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. ' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1412,7 +1421,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_enqueue_script_with_html5_support_does_not_contain_type_attribute() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wp_version;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_theme_support( 'html5', array( 'script' ) );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS['wp_scripts'] = new WP_Scripts();
</span><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS['wp_scripts']->default_version = get_bloginfo( 'version' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1421,7 +1429,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script src='http://example.com?ver={$wp_version}' id='empty-deps-no-version-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1460,7 +1468,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='{$wp_scripts->base_url}ftp://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver={$wp_version}' id='jquery-ftp-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Go!
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // No scripts left to print.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '', get_echo( 'wp_print_scripts' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1503,7 +1511,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='http://example.com' id='test-only-data-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Go!
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // No scripts left to print.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '', get_echo( 'wp_print_scripts' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1521,7 +1529,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<!--[if gt IE 7]>\n<script type='text/javascript' src='http://example.com' id='test-only-conditional-js'></script>\n<![endif]-->\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Go!
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // No scripts left to print.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '', get_echo( 'wp_print_scripts' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1539,9 +1547,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> wp_script_add_data( 'test-conditional-with-data', 'conditional', 'lt IE 9' );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<!--[if lt IE 9]>\n<script type='text/javascript' id='test-conditional-with-data-js-extra'>\n/* <![CDATA[ */\ntesting\n/* ]]> */\n</script>\n<![endif]-->\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<!--[if lt IE 9]>\n<script type='text/javascript' src='http://example.com' id='test-conditional-with-data-js'></script>\n<![endif]-->\n";
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = str_replace( "'", '"', $expected );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Go!
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // No scripts left to print.
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( '', get_echo( 'wp_print_scripts' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1559,10 +1568,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='http://example.com' id='test-invalid-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Go!
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // No scripts left to print.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( '', get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( '', get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1588,7 +1597,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'handle-three' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1676,8 +1685,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_header .= "<script type='text/javascript' src='/child-head.js' id='child-head-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_footer = "<script type='text/javascript' src='/parent.js' id='parent-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected_header, $header, 'Expected same header markup.' );
- $this->assertSame( $expected_footer, $footer, 'Expected same footer markup.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected_header, $header, 'Expected same header markup.' );
+ $this->assertEqualMarkup( $expected_footer, $footer, 'Expected same footer markup.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1697,8 +1706,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_footer = "<script type='text/javascript' src='/child-footer.js' id='child-footer-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_footer .= "<script type='text/javascript' src='/parent.js' id='parent-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected_header, $header, 'Expected same header markup.' );
- $this->assertSame( $expected_footer, $footer, 'Expected same footer markup.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected_header, $header, 'Expected same header markup.' );
+ $this->assertEqualMarkup( $expected_footer, $footer, 'Expected same footer markup.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1728,8 +1737,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_footer .= "<script type='text/javascript' src='/child2-footer.js' id='child2-footer-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_footer .= "<script type='text/javascript' src='/parent-footer.js' id='parent-footer-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected_header, $header, 'Expected same header markup.' );
- $this->assertSame( $expected_footer, $footer, 'Expected same footer markup.' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected_header, $header, 'Expected same header markup.' );
+ $this->assertEqualMarkup( $expected_footer, $footer, 'Expected same footer markup.' );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1952,6 +1961,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_localized = "<!--[if gte IE 9]>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_localized .= "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n/* ]]> */\n</script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected_localized .= "<![endif]-->\n";
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected_localized = str_replace( "'", '"', $expected_localized );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<!--[if gte IE 9]>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' id='test-example-js-before'>\nconsole.log(\"before\");\n</script>\n";
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1958,6 +1968,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' id='test-example-js-after'>\nconsole.log(\"after\");\n</script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<![endif]-->\n";
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = str_replace( "'", '"', $expected );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_enqueue_script( 'test-example', 'example.com', array(), null );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_localize_script( 'test-example', 'testExample', array( 'foo' => 'bar' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2124,7 +2135,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> _print_scripts();
</span><span class="cx" style="display: block; padding: 0 10px"> $print_scripts = $this->getActualOutput();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $tail = substr( $print_scripts, strrpos( $print_scripts, "<script type='text/javascript' src='/customize-dependency.js' id='customize-dependency-js'>" ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $tail = substr( $print_scripts, strrpos( $print_scripts, '<script type="text/javascript" src="/customize-dependency.js" id="customize-dependency-js">' ) );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEqualMarkup( $expected_tail, $tail );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2304,7 +2316,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js' id='test-example-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2331,7 +2343,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/wp-content/plugins/my-plugin/js/script.js' id='plugin-example-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2358,7 +2370,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/wp-content/themes/my-theme/js/script.js' id='theme-example-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2385,7 +2397,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/wp-admin/js/script.js' id='script-handle-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2415,7 +2427,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js' id='wp-i18n-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/wp-admin/js/script.js' id='test-example-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2444,7 +2456,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js' id='test-example-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2474,7 +2486,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js' id='test-dependency-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/wp-includes/js/script2.js' id='test-example-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSameIgnoreEOL( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2863,7 +2875,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected = "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {$expected};\n/* ]]> */\n</script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, get_echo( 'wp_print_scripts' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, get_echo( 'wp_print_scripts' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2928,7 +2940,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/plugins/wp-i18n.js' id='wp-i18n-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px"> $expected .= "<script type='text/javascript' src='/default/common.js' id='common-js'></script>\n";
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertSame( $expected, $print_scripts );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEqualMarkup( $expected, $print_scripts );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2967,7 +2979,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Parse an HTML markup fragment.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $markup Markup.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return DOMElement Body element wrapping supplied markup fragment.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return DOMDocument Document containing the normalized markup fragment.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function parse_markup_fragment( $markup ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $dom = new DOMDocument();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2985,11 +2997,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $body;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $dom;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Assert markup is equal.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Assert markup is equal after normalizing script tags.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $expected Expected markup.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $actual Actual markup.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2996,10 +3008,49 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $message Message.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> protected function assertEqualMarkup( $expected, $actual, $message = '' ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected_dom = $this->parse_markup_fragment( $expected );
+ $actual_dom = $this->parse_markup_fragment( $actual );
+ foreach ( array( $expected_dom, $actual_dom ) as $dom ) {
+ $xpath = new DOMXPath( $dom );
+ /** @var DOMElement $script */
+
+ // Normalize type attribute. When missing, it defaults to text/javascript.
+ foreach ( $xpath->query( '//script[ not( @type ) ]' ) as $script ) {
+ $script->setAttribute( 'type', 'text/javascript' );
+ }
+
+ // Normalize script contents to remove CDATA wrapper.
+ foreach ( $xpath->query( '//script[ contains( text(), "<![CDATA[" ) ]' ) as $script ) {
+ $script->textContent = str_replace(
+ array(
+ "/* <![CDATA[ */\n",
+ "\n/* ]]> */",
+ ),
+ '',
+ $script->textContent
+ );
+ }
+
+ // Normalize XHTML-compatible boolean attributes to HTML5 ones.
+ foreach ( array( 'async', 'defer' ) as $attribute ) {
+ foreach ( iterator_to_array( $xpath->query( "//script[ @{$attribute} = '{$attribute}' ]" ) ) as $script ) {
+ $script->removeAttribute( $attribute );
+ $script->setAttributeNode( $dom->createAttribute( $attribute ) );
+ }
+ }
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->parse_markup_fragment( $expected ),
- $this->parse_markup_fragment( $actual ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected_dom->getElementsByTagName( 'body' )->item( 0 ),
+ $actual_dom->getElementsByTagName( 'body' )->item( 0 ),
</ins><span class="cx" style="display: block; padding: 0 10px"> $message
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * Adds html5 script theme support.
+ */
+ protected function add_html5_script_theme_support() {
+ add_theme_support( 'html5', array( 'script' ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsdependencieswpInlineScriptTagphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/dependencies/wpInlineScriptTag.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/dependencies/wpInlineScriptTag.php 2023-09-25 20:47:32 UTC (rev 56686)
+++ trunk/tests/phpunit/tests/dependencies/wpInlineScriptTag.php 2023-09-25 21:03:19 UTC (rev 56687)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -119,4 +119,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * Tests that CDATA wrapper duplication is handled.
+ *
+ * @ticket 58664
+ */
+ public function test_get_inline_script_tag_with_duplicated_cdata_wrappers() {
+ remove_theme_support( 'html5' );
+
+ $this->assertSame(
+ "<script type=\"text/javascript\">\n/* <![CDATA[ */\n/* <![CDATA[ */ console.log( 'Hello World!' ); /* ]]]]><![CDATA[> */\n/* ]]> */\n</script>\n",
+ wp_get_inline_script_tag( "/* <![CDATA[ */ console.log( 'Hello World!' ); /* ]]> */" )
+ );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>