diff --git a/cypress/fixtures/checkbox.html b/cypress/fixtures/checkbox.html
new file mode 100644
index 0000000..5e0fb14
--- /dev/null
+++ b/cypress/fixtures/checkbox.html
@@ -0,0 +1,14 @@
+
+
+
+
diff --git a/cypress/integration/checkbox.browser.js b/cypress/integration/checkbox.browser.js
new file mode 100644
index 0000000..aea0ec0
--- /dev/null
+++ b/cypress/integration/checkbox.browser.js
@@ -0,0 +1,27 @@
+describe('checkboxes', function () {
+ beforeEach(function () {
+ cy.visit('/checkbox.html').then((win) => {
+ cy.wrap({ data: win.data });
+ });
+ });
+
+ it('should have checked boxes', () => {
+ cy.get('input:checked').should((t) => {
+ expect(t).have.length(1);
+ });
+ });
+
+ it.only('should check the box when data changes', () => {
+ let data;
+ cy.window()
+ .its('data')
+ .then((d) => {
+ data = d;
+ data.one = true;
+ })
+ .get('input:checked')
+ .should((t) => {
+ expect(t).have.length(2);
+ });
+ });
+});
diff --git a/lib/bind.js b/lib/bind.js
index 9851bc1..b3148b0 100644
--- a/lib/bind.js
+++ b/lib/bind.js
@@ -146,7 +146,8 @@ var Bind = (function Bind(global) {
var path = [].slice.call(_path);
var callback;
var transform = function (v) {
- return safe(v);
+ if (typeof v === 'string') return safe(v);
+ return v;
};
var parse = pass;
@@ -234,8 +235,8 @@ var Bind = (function Bind(global) {
// special case for multi-select items
var result = transform(value, target);
if (element.type === 'checkbox') {
- if (value instanceof Array) {
- var found = value.filter(function (value) {
+ if (result instanceof Array) {
+ var found = result.filter(function (value) {
if (value === element.value) {
element.checked = element.value === value;
return true;
@@ -245,7 +246,9 @@ var Bind = (function Bind(global) {
element.checked = false;
}
} else if (typeof result === 'boolean') {
- element.checked = value;
+ element.checked = result;
+ } else {
+ // console.log('no op');
}
} else if (element.type === 'radio') {
element.checked = element.value === result;