Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions test/bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<div data-html="value">text to be replaced</div>');
var view = reactive(el, { value: '<div data-html="value"></div>' });
assert(el.innerHTML === '<div data-html="value"></div>');
})
})
6 changes: 3 additions & 3 deletions test/reactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,15 @@ describe('data-replace', function(){
var input = document.createElement('input');
var el = domify('<div><div type="email" data-replace="input"></div>');
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('<div><div type="email" data-replace="input"></div>');
var view = reactive(el, {}, { delegate: { input: input } });
assert('url' == input.type);
assert('url' == input.getAttribute('type'));
})

it('should carryover classes', function(){
Expand Down