Skip to content

Commit

Permalink
Updates AMD definition and adds CommonJS
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Morris committed Mar 3, 2017
1 parent 365d97e commit 76a0b2a
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions src/jquery.form.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,32 @@
*/
/*global ActiveXObject */

// AMD support
(function (factory) {
"use strict";
if (typeof define === 'function' && define.amd) {
// using AMD; register as anon module
define(['jquery'], factory);
} if (typeof module !== 'undefined') {
factory(require('jquery'));
} else {
// no AMD; invoke directly
factory( (typeof(jQuery) != 'undefined') ? jQuery : window.Zepto );
}
}

(function($) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
module.exports = function( root, jQuery ) {
if ( jQuery === undefined ) {
// require('jQuery') returns a factory that requires window to build a jQuery instance, we normalize how we use modules
// that require this pattern but the window provided is a noop if it's defined (how jquery works)
if ( typeof window !== 'undefined' ) {
jQuery = require('jquery');
}
else {
jQuery = require('jquery')(root);
}
}
factory(jQuery);
return jQuery;
};
} else {
// Browser globals
factory(jQuery);
}

}(function ($) {
"use strict";

/*
Expand Down Expand Up @@ -1359,5 +1370,4 @@ function log() {
window.opera.postError(msg);
}
}

}));

0 comments on commit 76a0b2a

Please sign in to comment.