Skip to content

Commit

Permalink
Ensure apply is not called with undefined.
Browse files Browse the repository at this point in the history
Fixes a bug in IE8
Fixes #2225
  • Loading branch information
samccone committed Jan 30, 2015
1 parent 2478c5d commit be6f1b4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Marionette.proxyGetOption = function(optionName) {
// undefined return a default value
Marionette._getValue = function(value, context, params) {
if (_.isFunction(value)) {
// We need to ensure that params is not undefined
// to prevent `apply` from failing in ie8
params = params || [];

value = value.apply(context, params);
}
return value;
Expand Down

2 comments on commit be6f1b4

@jridgewell
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side thought: Why not do value = params ? value.apply(context, params) : value.call(context)? Might get a little speed boost.

@samccone
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah good call @jridgewell not opposed to that at all
want to open a PR into minor?
the goal here was really to get a patch fix out and we can iterate on the "fix"

👍 good call

Please sign in to comment.