Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
CRAP | n/a |
0 / 0 |
|
| jetpack_mu_wpcom_print_editor_polyfills | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Inline polyfills for built-ins the block editor calls without polyfilling. |
| 4 | * |
| 5 | * @package automattic/jetpack-mu-wpcom |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Print an Array.prototype.toSorted() polyfill ahead of every other admin script. |
| 10 | * |
| 11 | * Gutenberg 24.3 calls it unpolyfilled, which crashes the editor on Chrome < 110, Safari < 16 and Firefox < 115. |
| 12 | * Remove once core's wp-polyfill includes it (https://github.com/WordPress/gutenberg/pull/86159): the plugin uses core's copy. |
| 13 | */ |
| 14 | function jetpack_mu_wpcom_print_editor_polyfills() { |
| 15 | wp_print_inline_script_tag( |
| 16 | 'if(!Array.prototype.toSorted){Object.defineProperty(Array.prototype,"toSorted",{value:function(c){if(c!==void 0&&typeof c!=="function"){throw new TypeError("The comparison function must be either a function or undefined");}return Array.prototype.slice.call(this).sort(c);},writable:true,configurable:true});}' |
| 17 | ); |
| 18 | } |
| 19 | add_action( 'admin_print_scripts', 'jetpack_mu_wpcom_print_editor_polyfills', 0 ); |
| 20 | // The Customizer's block-based widget editor prints its scripts on its own hook. |
| 21 | add_action( 'customize_controls_print_scripts', 'jetpack_mu_wpcom_print_editor_polyfills', 0 ); |