File tree 3 files changed +19
-3
lines changed 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ class Modal extends Component {
59
59
} )
60
60
] ) ,
61
61
appElement : PropTypes . oneOfType ( [
62
- PropTypes . instanceOf ( SafeHTMLElement ) ,
62
+ SafeHTMLElement ,
63
63
PropTypes . instanceOf ( SafeHTMLCollection ) ,
64
64
PropTypes . instanceOf ( SafeNodeList ) ,
65
65
PropTypes . arrayOf ( PropTypes . instanceOf ( SafeHTMLElement ) )
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export default class ModalPortal extends Component {
47
47
htmlOpenClassName : PropTypes . string ,
48
48
ariaHideApp : PropTypes . bool ,
49
49
appElement : PropTypes . oneOfType ( [
50
- PropTypes . instanceOf ( SafeHTMLElement ) ,
50
+ SafeHTMLElement ,
51
51
PropTypes . instanceOf ( SafeHTMLCollection ) ,
52
52
PropTypes . instanceOf ( SafeNodeList ) ,
53
53
PropTypes . arrayOf ( PropTypes . instanceOf ( SafeHTMLElement ) )
Original file line number Diff line number Diff line change @@ -2,7 +2,23 @@ import ExecutionEnvironment from "exenv";
2
2
3
3
const EE = ExecutionEnvironment ;
4
4
5
- const SafeHTMLElement = EE . canUseDOM ? window . HTMLElement : { } ;
5
+ const NodeTypeElement = 1 ;
6
+
7
+ const IHTMLElement = function ( props , propName ) {
8
+ const element = props [ propName ] ;
9
+
10
+ if ( ! element || element . nodeType !== NodeTypeElement ) return ;
11
+
12
+ const isValid = Boolean ( element . setAttribute && element . removeAttribute ) ;
13
+
14
+ if ( ! isValid ) {
15
+ return new Error (
16
+ `Warning: Invalid prop \`${ propName } \` supplied to \`Modal\``
17
+ ) ;
18
+ }
19
+ } ;
20
+
21
+ export const SafeHTMLElement = EE . canUseDOM ? IHTMLElement : { } ;
6
22
7
23
export const SafeHTMLCollection = EE . canUseDOM ? window . HTMLCollection : { } ;
8
24
You can’t perform that action at this time.
0 commit comments