From c70a69aacecfbe704559ae40e78b3f390f0dd286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20M=C3=A6land?= Date: Mon, 1 Apr 2019 14:23:50 +0200 Subject: [PATCH] fix isReactComponent returning true for blank input --- dist/vuera.cjs.js | 1 + dist/vuera.es.js | 1 + dist/vuera.iife.js | 1 + src/utils/isReactComponent.js | 1 + tests/utils/isReactComponent-test.js | 6 ++++++ 5 files changed, 10 insertions(+) diff --git a/dist/vuera.cjs.js b/dist/vuera.cjs.js index a96c6ae..5011178 100644 --- a/dist/vuera.cjs.js +++ b/dist/vuera.cjs.js @@ -407,6 +407,7 @@ var ReactWrapper = { }; function isReactComponent(component) { + if (!component) return false; if ((typeof component === 'undefined' ? 'undefined' : _typeof(component)) === 'object' && !isReactForwardReference(component)) { return false; } diff --git a/dist/vuera.es.js b/dist/vuera.es.js index 7303e2e..5e23f0b 100644 --- a/dist/vuera.es.js +++ b/dist/vuera.es.js @@ -401,6 +401,7 @@ var ReactWrapper = { }; function isReactComponent(component) { + if (!component) return false; if ((typeof component === 'undefined' ? 'undefined' : _typeof(component)) === 'object' && !isReactForwardReference(component)) { return false; } diff --git a/dist/vuera.iife.js b/dist/vuera.iife.js index 7a93c1d..be895d6 100644 --- a/dist/vuera.iife.js +++ b/dist/vuera.iife.js @@ -404,6 +404,7 @@ var ReactWrapper = { }; function isReactComponent(component) { + if (!component) return false; if ((typeof component === 'undefined' ? 'undefined' : _typeof(component)) === 'object' && !isReactForwardReference(component)) { return false; } diff --git a/src/utils/isReactComponent.js b/src/utils/isReactComponent.js index 2ef847d..3387457 100644 --- a/src/utils/isReactComponent.js +++ b/src/utils/isReactComponent.js @@ -1,4 +1,5 @@ export default function isReactComponent (component) { + if (!component) return false if (typeof component === 'object' && !isReactForwardReference(component)) { return false } diff --git a/tests/utils/isReactComponent-test.js b/tests/utils/isReactComponent-test.js index 9ea97a8..40b68b8 100644 --- a/tests/utils/isReactComponent-test.js +++ b/tests/utils/isReactComponent-test.js @@ -20,4 +20,10 @@ describe('isReactComponent', () => { expect(isReactComponent(VueRegisteredComponent)).toBe(false) expect(isReactComponent(VueSingleFileComponent)).toBe(false) }) + + it('returns false for blank input', () => { + expect(isReactComponent(false)).toBe(false) + expect(isReactComponent(null)).toBe(false) + expect(isReactComponent(undefined)).toBe(false) + }) })