Script Loader: Load unminified package vendor scripts when `SCRIPT_DEBUG` is set.

The unminified package vendor scripts are bundled with the release package thus the value of the `SCRIPT_DEBUG` constant should be honored.

Props earnjam.
See #45535.
Built from https://develop.svn.wordpress.org/trunk@44391


git-svn-id: http://core.svn.wordpress.org/trunk@44221 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2019-01-04 20:27:49 +00:00
parent 0ee1a0e4e1
commit d31335da85
3 changed files with 49 additions and 42 deletions

View File

@ -300,11 +300,13 @@ class WP_Block_Parser {
*/ */
if ( 0 === $stack_depth ) { if ( 0 === $stack_depth ) {
if ( isset( $leading_html_start ) ) { if ( isset( $leading_html_start ) ) {
$this->output[] = (array) self::freeform( substr( $this->output[] = (array) self::freeform(
substr(
$this->document, $this->document,
$leading_html_start, $leading_html_start,
$start_offset - $leading_html_start $start_offset - $leading_html_start
) ); )
);
} }
$this->output[] = (array) new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ); $this->output[] = (array) new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() );
@ -323,13 +325,16 @@ class WP_Block_Parser {
case 'block-opener': case 'block-opener':
// track all newly-opened blocks on the stack. // track all newly-opened blocks on the stack.
array_push( $this->stack, new WP_Block_Parser_Frame( array_push(
$this->stack,
new WP_Block_Parser_Frame(
new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ), new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ),
$start_offset, $start_offset,
$token_length, $token_length,
$start_offset + $token_length, $start_offset + $token_length,
$leading_html_start $leading_html_start
) ); )
);
$this->offset = $start_offset + $token_length; $this->offset = $start_offset + $token_length;
return true; return true;
@ -422,22 +427,22 @@ class WP_Block_Parser {
return array( 'no-more-tokens', null, null, null, null ); return array( 'no-more-tokens', null, null, null, null );
} }
list( $match, $started_at ) = $matches[ 0 ]; list( $match, $started_at ) = $matches[0];
$length = strlen( $match ); $length = strlen( $match );
$is_closer = isset( $matches[ 'closer' ] ) && -1 !== $matches[ 'closer' ][ 1 ]; $is_closer = isset( $matches['closer'] ) && -1 !== $matches['closer'][1];
$is_void = isset( $matches[ 'void' ] ) && -1 !== $matches[ 'void' ][ 1 ]; $is_void = isset( $matches['void'] ) && -1 !== $matches['void'][1];
$namespace = $matches[ 'namespace' ]; $namespace = $matches['namespace'];
$namespace = ( isset( $namespace ) && -1 !== $namespace[ 1 ] ) ? $namespace[ 0 ] : 'core/'; $namespace = ( isset( $namespace ) && -1 !== $namespace[1] ) ? $namespace[0] : 'core/';
$name = $namespace . $matches[ 'name' ][ 0 ]; $name = $namespace . $matches['name'][0];
$has_attrs = isset( $matches[ 'attrs' ] ) && -1 !== $matches[ 'attrs' ][ 1 ]; $has_attrs = isset( $matches['attrs'] ) && -1 !== $matches['attrs'][1];
/* /*
* Fun fact! It's not trivial in PHP to create "an empty associative array" since all arrays * Fun fact! It's not trivial in PHP to create "an empty associative array" since all arrays
* are associative arrays. If we use `array()` we get a JSON `[]` * are associative arrays. If we use `array()` we get a JSON `[]`
*/ */
$attrs = $has_attrs $attrs = $has_attrs
? json_decode( $matches[ 'attrs' ][ 0 ], /* as-associative */ true ) ? json_decode( $matches['attrs'][0], /* as-associative */ true )
: $this->empty_attrs; : $this->empty_attrs;
/* /*
@ -536,11 +541,13 @@ class WP_Block_Parser {
} }
if ( isset( $stack_top->leading_html_start ) ) { if ( isset( $stack_top->leading_html_start ) ) {
$this->output[] = (array) self::freeform( substr( $this->output[] = (array) self::freeform(
substr(
$this->document, $this->document,
$stack_top->leading_html_start, $stack_top->leading_html_start,
$stack_top->token_start - $stack_top->leading_html_start $stack_top->token_start - $stack_top->leading_html_start
) ); )
);
} }
$this->output[] = (array) $stack_top->block; $this->output[] = (array) $stack_top->block;

View File

@ -76,7 +76,7 @@ function wp_register_tinymce_scripts( &$scripts, $force_uncompressed = false ) {
function wp_default_packages_vendor( &$scripts ) { function wp_default_packages_vendor( &$scripts ) {
global $wp_locale; global $wp_locale;
$dev_suffix = wp_scripts_get_suffix( 'dev' ); $suffix = wp_scripts_get_suffix();
$vendor_scripts = array( $vendor_scripts = array(
'react' => array( 'wp-polyfill' ), 'react' => array( 'wp-polyfill' ),
@ -108,7 +108,7 @@ function wp_default_packages_vendor( &$scripts ) {
$dependencies = array(); $dependencies = array();
} }
$path = "/wp-includes/js/dist/vendor/$handle$dev_suffix.js"; $path = "/wp-includes/js/dist/vendor/$handle$suffix.js";
$version = $vendor_scripts_versions[ $handle ]; $version = $vendor_scripts_versions[ $handle ];
$scripts->add( $handle, $path, $dependencies, $version, 1 ); $scripts->add( $handle, $path, $dependencies, $version, 1 );

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.1-alpha-44389'; $wp_version = '5.1-alpha-44391';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.