Skip to content
Permalink
Browse files
fixed the jquery plugin code and increased version number to 2.0
  • Loading branch information
EvanCarroll committed Oct 29, 2015
1 parent 0acf660 commit 2bbe19cc557fb1b99691932911e533cdc391d1f5
Showing with 42 additions and 3 deletions.
  1. +21 −0 CHANGES
  2. +17 −2 jqueryPlugin.js
  3. +4 −1 package.json
21 CHANGES
@@ -0,0 +1,21 @@

v2.0.0

* jQuery is now provided by only one template. This template normalizes how
modules built with it are used in CommonJS environments:

require('./myJqueryPlugin')(window, [jQuery]);


Providing window is mandated. This is because jQuery upstream,

1. Sometimes returns a factory, and only sometimes.
2. We *always* have access to window.
3. It makes the use of window explicit.
4. If jQuery ever provides access to the factory we are forward-compatable.

For more information on this, read

* http://stackoverflow.com/q/33404108/124486
* https://github.com/umdjs/umd/issues/68

@@ -6,11 +6,26 @@
define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
module.exports = factory(require('jquery'));
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 ( window ) {
jQuery = require('jquery');
}
else {
jQuery = require('jquery')(root);
}
}
factory(jQuery);
return jQuery;
};
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
$.fn.jqueryPlugin = function () {};
$.fn.jqueryPlugin = function () { return true; };
}));
@@ -1,6 +1,6 @@
{
"name": "umdjs",
"version": "1.0.0",
"version": "2.0.0",
"description": "UMD (Universal Module Definition)",
"main": "amdWeb.js",
"repository": {
@@ -26,5 +26,8 @@
},
"devDependencies": {
"jshint": "^2.8.0"
},
"dependencies": {
"jquery": "^2.1.4"
}
}

0 comments on commit 2bbe19c

Please sign in to comment.