Skip to content

Commit

Permalink
Use array.from() to conver the nodelist to an array for firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
jeryj committed Jun 26, 2024
1 parent 69a8579 commit 637978a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions packages/block-editor/src/utils/get-editor-region.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Gets the editor region for a given editor canvas element or
* returns the passed element if no region is found
*
* @param { Object } editor
* @param { Object } editor The editor canvas element.
* @return { Object } The editor region or given editor element
*/
export default function getEditorRegion( editor ) {
Expand All @@ -13,16 +13,15 @@ export default function getEditorRegion( editor ) {
// If there are multiple editors, we need to find the iframe that contains our contentRef to make sure
// we're focusing the region that contains this editor.
const editorCanvas =
document
.querySelectorAll( 'iframe[name="editor-canvas"]' )
.values()
.find( ( iframe ) => {
// Find the iframe that contains our contentRef
const iframeDocument =
iframe.contentDocument || iframe.contentWindow.document;
Array.from(
document.querySelectorAll( 'iframe[name="editor-canvas"]' ).values()
).find( ( iframe ) => {
// Find the iframe that contains our contentRef
const iframeDocument =
iframe.contentDocument || iframe.contentWindow.document;

return iframeDocument === editor.ownerDocument;
} ) ?? editor;
return iframeDocument === editor.ownerDocument;
} ) ?? editor;

// The region is provivided by the editor, not the block-editor.
// We should send focus to the region if one is available to reuse the
Expand Down

0 comments on commit 637978a

Please sign in to comment.