Skip to content

Commit

Permalink
Merge pull request #3542 from akre54/jq-require
Browse files Browse the repository at this point in the history
Wrap commonjs jQuery require in a try-catch
  • Loading branch information
jashkenas committed Mar 25, 2015
2 parents 4f58c5b + b2a10af commit 43818cc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions backbone.js
Expand Up @@ -17,8 +17,9 @@

// Next for Node.js or CommonJS. jQuery may not be needed as a module.
} else if (typeof exports !== 'undefined') {
var _ = require('underscore');
factory(root, exports, _);
var _ = require('underscore'), $;
try { $ = require('jquery'); } catch(e) {}
factory(root, exports, _, $);

// Finally, as a browser global.
} else {
Expand Down Expand Up @@ -277,7 +278,7 @@
// receive the true name of the event as the first argument).
Events.trigger = function(name) {
if (!this._events) return this;

var length = Math.max(0, arguments.length - 1);
var args = Array(length);
for (var i = 0; i < length; i++) args[i] = arguments[i + 1];
Expand Down

0 comments on commit 43818cc

Please sign in to comment.