diff --git a/.size-snapshot.json b/.size-snapshot.json index 992fd92..bbe82bb 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -1,12 +1,12 @@ { "dist/react-input-mask.js": { - "bundled": 38128, - "minified": 13804, - "gzipped": 4839 + "bundled": 38566, + "minified": 13915, + "gzipped": 4878 }, "lib/react-input-mask.development.js": { - "bundled": 33933, - "minified": 14851, - "gzipped": 4649 + "bundled": 34353, + "minified": 14960, + "gzipped": 4689 } } diff --git a/src/index.js b/src/index.js index eb9156b..f6f00fc 100644 --- a/src/index.js +++ b/src/index.js @@ -69,6 +69,12 @@ class InputElement extends React.Component { componentDidMount() { this.mounted = true; + // workaround for react-test-renderer + // https://github.com/sanniassin/react-input-mask/issues/147 + if (!this.getInputDOMNode()) { + return; + } + this.isWindowsPhoneBrowser = isWindowsPhoneBrowser(); if (this.maskOptions.mask && this.getInputValue() !== this.value) { @@ -200,6 +206,15 @@ class InputElement extends React.Component { } let input = findDOMNode(this); + const isDOMNode = typeof window !== 'undefined' + && + input instanceof window.HTMLElement; + + // workaround for react-test-renderer + // https://github.com/sanniassin/react-input-mask/issues/147 + if (input && !isDOMNode) { + return null; + } if (input.nodeName !== 'INPUT') { input = input.querySelector('input');