added: 'onSet' & 'onRemove' callback support#315
added: 'onSet' & 'onRemove' callback support#315MarQuisKnox wants to merge 9 commits intocarhartl:masterfrom
Conversation
added: 'onSet' & 'onRemove' callback support
Travis was complaining...
Travis was crying...
should pass all CI tests now
src/jquery.cookie.js
Outdated
There was a problem hiding this comment.
Hm..
if( typeof options.onSet === 'undefined' ) {
} else {
if( typeof options.onSet === 'function' ) {
..
}
}This can just be reduced to:
if( typeof options.onSet === 'function' ) {
..
}Or even:
if( options.onSet ) {
..
}|
You misunderstood the error from Travis (and presumably didn't test the code).
|
|
In javascript, parameters are quite flexible. There is no need to declare them in order to pass them as arguments in a custom version of the function (or even at all). When JSHint complained about unused parameters in the default function, the solution is to remove the parameter, not to insert a confusing return statement that uses the variable. - onSet: function( result ) {}
+ onSet: function() {} |
|
The first commit works in the browser: MarQuisKnox@2ce5bdd The other stuff I just did to try to pass the Travis CI tests. I will look at it again when I have time to install grunt et al locally. No time now. It works in the browser (Waterfox 30) — didn't test any others. Also, just FYI, I would not have requested a PR on the initial commit if it did not work. |
|
@MarQuisKnox I'd recommend going back to that first commit and only updating it to:
The warning for |
|
@Krinkle I just cleaned up the PR. Let me know if anything else needs to be changed. Thanks. |
|
Thanks for the PR. Though I don't really see the need for this. The cookie operations are not asynchronous. So $.cookie('foo', 'bar');
alert('onSet');If you need it to implement some sort of pub/sub pattern in a larger application this should be implemented right there, since it is too specific a use case for this lightweight plugin: App.setCookie = function(name, value, options) {
cookie = $.cookie.apply(null, arguments);
publish('cookie:set', cookie);
}(pseudo code) |
added: 'onSet' & 'onRemove' callback support