gutenberg
gutenberg copied to clipboard
`gutenberg_register_packages_scripts()` can only be run once
Describe the bug
If gutenberg_register_packages_scripts() is run more than once, the dependencies for any packages' scripts with a core handle are removed.
The require_once() call will return true on all but the first run of gutenberg_register_packages_scripts(), which will wipe out any dependencies.
https://github.com/WordPress/gutenberg/blob/6fc0b707331e293c20866963b342cf2a4ca913de/lib/client-assets.php#L240-L243
Introduced in #17298.
To reproduce Steps to reproduce the behavior:
- Install an mu-plugin:
<?php add_action( 'after_setup_theme', function() { wp_enqueue_script( 'jquery' ); } ); add_action( 'init', function() { wp_enqueue_script( 'wp-a11y' ); } ); - Go to the homepage.
- See the following error in the JS Console:
Uncaught TypeError: o(...) is not a function at Module.321 (index.js?ver=1574117808:1) at n (index.js?ver=1574117808:1) at wp.a11y.186 (index.js?ver=1574117808:1) at index.js?ver=1574117808:1 - View the homepage's HTML source.
- See that
a11yhas been included, but notdom-ready.
Expected behavior
gutenberg_register_packages_scripts() should be able to be run more than once.
Additional context
- Gutenberg 6.9.0