Skip to content

Commit 2ac7e8b

Browse files
author
Jean-Christophe Cazeaux
committed
Report for PR mikeric#612 Set bound to false when unbinding 'if' binder
1 parent 9760c25 commit 2ac7e8b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

spec/rivets/binders.js

+18
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,23 @@ describe("Rivets.binders", function() {
183183
// 1 for the comment placeholder
184184
Should(fragment.childNodes.length).be.exactly(1);
185185
});
186+
187+
it("rebindes nested if", function() {
188+
var nestedEl = document.createElement("div")
189+
nestedEl.setAttribute("rv-if", "data.showNested");
190+
nestedEl.innerHTML = "{ data.countNested }";
191+
el.appendChild(nestedEl);
192+
193+
var view = rivets.bind(fragment, model);
194+
195+
model.data.countNested = "1";
196+
model.data.showNested = true;
197+
Should(nestedEl.innerHTML).be.exactly("1");
198+
model.data.show = false;
199+
model.data.show = true;
200+
model.data.countNested = "42";
201+
202+
Should(nestedEl.innerHTML).be.exactly("42");
203+
});
186204
});
187205
});

src/binders.js

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ const binders = {
158158
unbind: function() {
159159
if (defined(this.nested)) {
160160
this.nested.unbind()
161+
this.bound = false
161162
}
162163
},
163164

0 commit comments

Comments
 (0)