Skip to content

Commit

Permalink
Fix incompatibility with react-test-renderer (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanniassin committed Aug 6, 2018
1 parent 4e10927 commit f54651b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
12 changes: 6 additions & 6 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
@@ -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
}
}
15 changes: 15 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit f54651b

Please sign in to comment.