From 59a922de2bff9b5b4c3251a61262bbaa6428f8f7 Mon Sep 17 00:00:00 2001 From: Robert-Frampton Date: Mon, 2 Oct 2017 15:09:45 -0700 Subject: [PATCH 1/2] Don't attempt to create element in Node.js environment --- packages/metal-incremental-dom/src/render/patch.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/metal-incremental-dom/src/render/patch.js b/packages/metal-incremental-dom/src/render/patch.js index 3b948d11..1490ee56 100644 --- a/packages/metal-incremental-dom/src/render/patch.js +++ b/packages/metal-incremental-dom/src/render/patch.js @@ -2,6 +2,7 @@ import { append, exitDocument } from 'metal-dom'; import { getData } from '../data'; +import { isFunction } from 'metal'; import { render } from './render'; const patchingComponents_ = []; @@ -15,7 +16,10 @@ const patchingComponents_ = []; */ function buildParentIfNecessary_(element) { if (!element || !element.parentNode) { - const parent = document.createElement('div'); + let parent = {}; + if (typeof document !== 'undefined' && isFunction(document.createElement)) { + parent = document.createElement('div'); + } if (element) { append(parent, element); } From c2a316dae2cd72efbb0230746bda81b1b38637ed Mon Sep 17 00:00:00 2001 From: Robert-Frampton Date: Tue, 3 Oct 2017 09:36:02 -0700 Subject: [PATCH 2/2] Use core.isServerSide for checking environment --- packages/metal-incremental-dom/src/render/patch.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/metal-incremental-dom/src/render/patch.js b/packages/metal-incremental-dom/src/render/patch.js index 1490ee56..942e1557 100644 --- a/packages/metal-incremental-dom/src/render/patch.js +++ b/packages/metal-incremental-dom/src/render/patch.js @@ -2,7 +2,7 @@ import { append, exitDocument } from 'metal-dom'; import { getData } from '../data'; -import { isFunction } from 'metal'; +import { isServerSide } from 'metal'; import { render } from './render'; const patchingComponents_ = []; @@ -17,7 +17,7 @@ const patchingComponents_ = []; function buildParentIfNecessary_(element) { if (!element || !element.parentNode) { let parent = {}; - if (typeof document !== 'undefined' && isFunction(document.createElement)) { + if (!isServerSide()) { parent = document.createElement('div'); } if (element) {