diff --git a/spec/rivets/binders.js b/spec/rivets/binders.js index 2150aa46c..e0abc9208 100644 --- a/spec/rivets/binders.js +++ b/spec/rivets/binders.js @@ -184,4 +184,25 @@ describe("Rivets.binders", function() { Should(fragment.childNodes.length).be.exactly(1); }); }); + + describe("Custom binder with no attribute value", function() { + rivets.binders["custom-binder"] = function(el, value) { + el.innerHTML = "received " + value; + }; + beforeEach(function() { + el = document.createElement("div"); + }); + + it("receives undefined when html attribute is not specified", function() { + el.innerHTML = "
"; + var view = rivets.bind(el); + Should(el.children[0].innerHTML).be.exactly('received undefined'); + }); + + it("receives undefined when html attribute is not specified", function() { + el.innerHTML = "
"; + var view = rivets.bind(el); + Should(el.children[0].innerHTML).be.exactly('received undefined'); + }); + }); }); diff --git a/src/parsers.js b/src/parsers.js index 8146c8b6c..4a29cbb2f 100644 --- a/src/parsers.js +++ b/src/parsers.js @@ -18,6 +18,9 @@ export function parseType(string) { value = null } else if (string === 'undefined') { value = undefined + } else if (string === '') { + // string==='' means the Html attribute is empty, binder should receive undefined + value = undefined } else if (isNaN(Number(string)) === false) { value = Number(string) } else {