diff --git a/lib/index.js b/lib/index.js
index 996aaca..6925af2 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -266,7 +266,7 @@ Reactive.prototype._bind = function() {
return next(skip);
}
// text
- else if (el.nodeType == 3) {
+ else if (el.nodeType == 3 && el.parentNode) {
if (utils.hasInterpolation(el.data)) {
debug('bind text "%s"', el.data);
new TextBinding(self, el);
diff --git a/test/bindings.js b/test/bindings.js
index e804248..d392aee 100644
--- a/test/bindings.js
+++ b/test/bindings.js
@@ -103,3 +103,11 @@ describe('Reactive#bind(name, fn)', function(){
assert(el.value == 'value');
})
})
+
+describe('data-html', function () {
+ it('should replace html content', function(){
+ var el = domify('
text to be replaced
');
+ var view = reactive(el, { value: '' });
+ assert(el.innerHTML === '');
+ })
+})
diff --git a/test/reactive.js b/test/reactive.js
index 0e0bb08..5b545c9 100644
--- a/test/reactive.js
+++ b/test/reactive.js
@@ -313,15 +313,15 @@ describe('data-replace', function(){
var input = document.createElement('input');
var el = domify('');
var view = reactive(el, {}, { delegate: { input: input } });
- assert('email' == input.type);
+ assert('email' == input.getAttribute('type'));
})
it('shouldnt wipe out existing attributes', function(){
var input = document.createElement('input');
- input.type = 'url'
+ input.setAttribute('type', 'url')
var el = domify('
');
var view = reactive(el, {}, { delegate: { input: input } });
- assert('url' == input.type);
+ assert('url' == input.getAttribute('type'));
})
it('should carryover classes', function(){