Skip to content

Commit

Permalink
Adding param validation and missing-binding errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmac committed Jan 17, 2014
1 parent a80fb98 commit f86ceae
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions backbone.epoxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,9 +921,17 @@
})
};

// Define allowed binding parameters:
// These params may be included in binding handlers without throwing errors.
var allowedParams = {
events: 1,
optionsDefault: 1,
optionsEmpty: 1
};

// Define binding API:
Epoxy.binding = {
allowedParams: allowedParams,
addHandler: function(name, handler) {
bindingHandlers[ name ] = makeHandler(handler);
},
Expand Down Expand Up @@ -1215,6 +1223,8 @@
if (handlers.hasOwnProperty(handlerName)) {
// Create and add binding to the view's list of handlers:
view.b().push(new EpoxyBinding($element, handlers[handlerName], accessor, events, context, bindings));
} else if (!allowedParams.hasOwnProperty(handlerName)) {
throw('binding handler "'+ handlerName +'" is not defined.');
}
});
}
Expand Down
Loading

0 comments on commit f86ceae

Please sign in to comment.