File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
33import ParallaxContext from '../helpers/ParallaxContext' ;
44import ParallaxController from '../classes/ParallaxController' ;
55import { VERTICAL , HORIZONTAL } from '../constants' ;
6+ import validHTMLElement from '../utils/validHTMLElement' ;
67
78const createController = options => {
89 // Don't initialize on the server
@@ -23,7 +24,7 @@ export default class ParallaxProvider extends Component {
2324 static propTypes = {
2425 children : PropTypes . node . isRequired ,
2526 scrollAxis : PropTypes . oneOf ( [ VERTICAL , HORIZONTAL ] ) ,
26- scrollContainer : PropTypes . instanceOf ( Element ) ,
27+ scrollContainer : validHTMLElement ,
2728 } ;
2829
2930 constructor ( props ) {
Original file line number Diff line number Diff line change 1+ export default function validHTMLElement (
2+ props ,
3+ propName ,
4+ componentName = 'ANONYMOUS'
5+ ) {
6+ if ( typeof window === 'undefined' ) {
7+ return null ;
8+ }
9+
10+ if ( props [ propName ] ) {
11+ const value = props [ propName ] ;
12+ const isValid = value instanceof window . Element ;
13+
14+ if ( ! isValid ) {
15+ return new Error (
16+ `Prop name "${ propName } " in <${ componentName } > must be an HTML DOM element.`
17+ ) ;
18+ }
19+ }
20+
21+ return null ;
22+ }
You can’t perform that action at this time.
0 commit comments