diff --git a/packages/blocks/src/api/raw-handling/list-reducer.js b/packages/blocks/src/api/raw-handling/list-reducer.js index a5f079dcb2488..a5e85949aea62 100644 --- a/packages/blocks/src/api/raw-handling/list-reducer.js +++ b/packages/blocks/src/api/raw-handling/list-reducer.js @@ -8,7 +8,7 @@ function isList( node ) { } function shallowTextContent( element ) { - return [ ...element.childNodes ] + return Array.from( element.childNodes ) .map( ( { nodeValue = '' } ) => nodeValue ) .join( '' ); } diff --git a/packages/blocks/src/api/validation.js b/packages/blocks/src/api/validation.js index 444830c47c5ac..6c0b98b69725f 100644 --- a/packages/blocks/src/api/validation.js +++ b/packages/blocks/src/api/validation.js @@ -50,7 +50,7 @@ const REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/; * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3 * - * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ] + * Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) ) * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 ) * .reduce( ( result, tr ) => Object.assign( result, { * [ tr.firstChild.textContent.trim() ]: true @@ -97,7 +97,7 @@ const BOOLEAN_ATTRIBUTES = [ * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3 * - * Object.keys( [ ...document.querySelectorAll( '#attributes-1 > tbody > tr' ) ] + * Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) ) * .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) ) * .reduce( ( result, tr ) => Object.assign( result, { * [ tr.firstChild.textContent.trim() ]: true @@ -164,9 +164,9 @@ const TEXT_NORMALIZATIONS = [ * Tested aginst "12.5 Named character references": * * ``` - * const references = [ ...document.querySelectorAll( + * const references = Array.from( document.querySelectorAll( * '#named-character-references-table tr[id^=entity-] td:first-child' - * ) ].map( ( code ) => code.textContent ) + * ) ).map( ( code ) => code.textContent ) * references.every( ( reference ) => /^[\da-z]+$/i.test( reference ) ) * ``` * diff --git a/packages/components/src/disabled/test/index.js b/packages/components/src/disabled/test/index.js index bd7c556163e4e..54120a61a61bc 100644 --- a/packages/components/src/disabled/test/index.js +++ b/packages/components/src/disabled/test/index.js @@ -25,7 +25,7 @@ jest.mock( '@wordpress/dom', () => { // In JSDOM, all elements have zero'd widths and height. // This is a metric for focusable's `isVisible`, so find // and apply an arbitrary non-zero width. - [ ...context.querySelectorAll( '*' ) ].forEach( ( element ) => { + Array.from( context.querySelectorAll( '*' ) ).forEach( ( element ) => { Object.defineProperties( element, { offsetWidth: { get: () => 1, diff --git a/packages/components/src/draggable/index.js b/packages/components/src/draggable/index.js index ac077468d8377..cd7d8c310e953 100644 --- a/packages/components/src/draggable/index.js +++ b/packages/components/src/draggable/index.js @@ -116,7 +116,7 @@ class Draggable extends Component { } // Hack: Remove iFrames as it's causing the embeds drag clone to freeze - [ ...clone.querySelectorAll( 'iframe' ) ].forEach( ( child ) => child.parentNode.removeChild( child ) ); + Array.from( clone.querySelectorAll( 'iframe' ) ).forEach( ( child ) => child.parentNode.removeChild( child ) ); this.cloneWrapper.appendChild( clone ); elementWrapper.appendChild( this.cloneWrapper ); diff --git a/packages/components/src/higher-order/navigate-regions/index.js b/packages/components/src/higher-order/navigate-regions/index.js index c716e2d1ea9f1..b8b010a7414f4 100644 --- a/packages/components/src/higher-order/navigate-regions/index.js +++ b/packages/components/src/higher-order/navigate-regions/index.js @@ -34,7 +34,7 @@ export default createHigherOrderComponent( } focusRegion( offset ) { - const regions = [ ...this.container.querySelectorAll( '[role="region"]' ) ]; + const regions = Array.from( this.container.querySelectorAll( '[role="region"]' ) ); if ( ! regions.length ) { return; } diff --git a/packages/dom/src/focusable.js b/packages/dom/src/focusable.js index 133b89d366974..12688755cfe44 100644 --- a/packages/dom/src/focusable.js +++ b/packages/dom/src/focusable.js @@ -76,7 +76,7 @@ function isValidFocusableArea( element ) { export function find( context ) { const elements = context.querySelectorAll( SELECTOR ); - return [ ...elements ].filter( ( element ) => { + return Array.from( elements ).filter( ( element ) => { if ( ! isVisible( element ) ) { return false; } diff --git a/packages/edit-post/src/components/admin-notices/index.js b/packages/edit-post/src/components/admin-notices/index.js index af04efaa9953a..d39c74c34a062 100644 --- a/packages/edit-post/src/components/admin-notices/index.js +++ b/packages/edit-post/src/components/admin-notices/index.js @@ -27,7 +27,7 @@ const NOTICE_CLASS_STATUSES = { function getAdminNotices() { // The order is reversed to match expectations of rendered order, since a // NoticesList is itself rendered in reverse order (newest to oldest). - return [ ...document.querySelectorAll( '#wpbody-content > .notice' ) ].reverse(); + return Array.from( document.querySelectorAll( '#wpbody-content > .notice' ) ).reverse(); } /**