Script Loader: Add polyfill for window.URL, window.DOMRect.

Pending block editor revisions for WordPress 5.4 will make use of `window.URL` and `window.DOMRect`. These are not available in Internet Explorer (or pre-Chromium Edge for `DOMRect`) and must be polyfilled to avoid script errors.

The changes make use of the existing polyfill pattern, and existing `polyfill-library` dependency. The dependency is bumped to the latest version, since the previous version did not include the `DOMRect` polyfill.

Props jorgefilipecosta.
Fixes #49360.


git-svn-id: https://develop.svn.wordpress.org/trunk@47238 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Duthie
2020-02-10 15:15:07 +00:00
parent 5b0be97e7c
commit 2c795289c8
5 changed files with 191 additions and 672 deletions

View File

@@ -86,6 +86,8 @@ function wp_default_packages_vendor( &$scripts ) {
'wp-polyfill-fetch',
'wp-polyfill-formdata',
'wp-polyfill-node-contains',
'wp-polyfill-url',
'wp-polyfill-dom-rect',
'wp-polyfill-element-closest',
'wp-polyfill',
);
@@ -97,7 +99,9 @@ function wp_default_packages_vendor( &$scripts ) {
'lodash' => '4.17.15',
'wp-polyfill-fetch' => '3.0.0',
'wp-polyfill-formdata' => '3.0.12',
'wp-polyfill-node-contains' => '3.26.0-0',
'wp-polyfill-node-contains' => '3.42.0',
'wp-polyfill-url' => '3.42.0',
'wp-polyfill-dom-rect' => '3.42.0',
'wp-polyfill-element-closest' => '2.0.2',
'wp-polyfill' => '7.4.4',
);
@@ -122,6 +126,8 @@ function wp_default_packages_vendor( &$scripts ) {
array(
'\'fetch\' in window' => 'wp-polyfill-fetch',
'document.contains' => 'wp-polyfill-node-contains',
'window.URL' => 'wp-polyfill-url',
'window.DOMRect' => 'wp-polyfill-dom-rect',
'window.FormData && window.FormData.prototype.keys' => 'wp-polyfill-formdata',
'Element.prototype.matches && Element.prototype.closest' => 'wp-polyfill-element-closest',
)