From fe960bc2f364537a9e8abfa8b2b83a18a993cd3b Mon Sep 17 00:00:00 2001 From: Jon Eisen Date: Wed, 3 Sep 2014 18:02:52 -0600 Subject: [PATCH 1/4] Dont process removed nodes --- lib/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/index.js b/lib/index.js index 996aaca..3ad7f11 100644 --- a/lib/index.js +++ b/lib/index.js @@ -215,6 +215,9 @@ Reactive.prototype._bind = function() { var bindings = self.bindings; walk(self.el, function(el, next) { + if (!el.parentNode) // Don't process removed nodes + return next() + // element if (el.nodeType == 1) { var skip = false; From 2dfe287f79f4aeb8891c07689ea4f944b5c0699a Mon Sep 17 00:00:00 2001 From: Jon Eisen Date: Wed, 3 Sep 2014 18:08:21 -0600 Subject: [PATCH 2/4] dont interpolate removed text nodes --- lib/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index 3ad7f11..6925af2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -215,9 +215,6 @@ Reactive.prototype._bind = function() { var bindings = self.bindings; walk(self.el, function(el, next) { - if (!el.parentNode) // Don't process removed nodes - return next() - // element if (el.nodeType == 1) { var skip = false; @@ -269,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); From a70d217be3686bb296d29548587d0d2b7084cb47 Mon Sep 17 00:00:00 2001 From: Jon Eisen Date: Thu, 4 Sep 2014 14:23:21 -0600 Subject: [PATCH 3/4] Add test for data-html replacing text --- test/bindings.js | 8 ++++++++ 1 file changed, 8 insertions(+) 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 === '
'); + }) +}) From 711e28e9b6877c9f1b1f9b679ca384be997e16da Mon Sep 17 00:00:00 2001 From: Jon Eisen Date: Thu, 4 Sep 2014 14:23:45 -0600 Subject: [PATCH 4/4] Make tests IE9 compatible (type=email doesnt work, so use set/getAttribute) --- test/reactive.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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(){