From 2cf596cb81553525848e0d7e95cdfdbc0acbc1d7 Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Thu, 26 Jan 2023 22:26:25 +0900 Subject: [PATCH] `useDisabled` hook: Fix problem with not working in iframe --- packages/compose/src/hooks/use-disabled/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/compose/src/hooks/use-disabled/index.ts b/packages/compose/src/hooks/use-disabled/index.ts index 7a384cbcc546f7..64b56b1f9a8682 100644 --- a/packages/compose/src/hooks/use-disabled/index.ts +++ b/packages/compose/src/hooks/use-disabled/index.ts @@ -39,11 +39,16 @@ export default function useDisabled( { return; } + const defaultView = node?.ownerDocument?.defaultView; + if ( ! defaultView ) { + return; + } + /** A variable keeping track of the previous updates in order to restore them. */ const updates: Function[] = []; const disable = () => { node.childNodes.forEach( ( child ) => { - if ( ! ( child instanceof HTMLElement ) ) { + if ( ! ( child instanceof defaultView.HTMLElement ) ) { return; } if ( ! child.getAttribute( 'inert' ) ) {