Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/morph-range.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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 */
Expand All @@ -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');
Expand Down