From 4384bbae291f677b9a783f1b6b46dd7b58fe22e5 Mon Sep 17 00:00:00 2001 From: Roman Sandler Date: Mon, 17 Oct 2016 16:37:05 +1100 Subject: [PATCH] support callable HTMLObjectElement --- lib/morph-range.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/morph-range.js b/lib/morph-range.js index 972957b..61c41d8 100644 --- a/lib/morph-range.js +++ b/lib/morph-range.js @@ -1,5 +1,9 @@ import { clear, insertBefore } from './morph-range/utils'; +function isDomNode(content) { + return typeof content.nodeType === 'number'; +} + // constructor just initializes the fields // use one of the static initializers to create a valid morph. function Morph(domHelper, contextualElement) { @@ -51,7 +55,7 @@ Morph.prototype.setContent = function Morph$setContent(content) { } return this.setText(content); case 'object': - if (typeof content.nodeType === 'number') { + if (isDomNode(content)) { return this.setNode(content); } /* Handlebars.SafeString */ @@ -66,6 +70,9 @@ Morph.prototype.setContent = function Morph$setContent(content) { case 'number': return this.setText(content.toString()); case 'function': + if (isDomNode(content)) { + return this.setNode(content); + } raiseCannotBindToFunction(content); default: throw new TypeError('unsupported content');