Package Exports
- jquery-with-dom
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jquery-with-dom) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
jquery-with-dom.js
I don't want what the jquery npm gives me, and I don't want a custom install, so export an instance of jQuery from jsdom, so it can do dom manipulation and selection, this is much more what I need for building and testing UMD modules.
just include like this:
(function (root, factory) {
if (typeof define === 'function' && define.amd){
define(['jquery'], factory);
} else if (typeof exports === 'object'){
module.exports = factory(require('jquery-with-dom'));
} else {
root.jQuery = factory(root.$ || root.jQuery);
}
}(this, function ($) {
$.ready(function(jQuery){
$ = jQuery;
});
function aSafeAsyncFunctionThatNeedsJQuery(callback){
$.ready(function(){
//do stuff
callback();
});
}
function iPromiseToEnsureJQueryIsLoadedBeforeCalling(callback){
// go crazy, use $ wherever
}
return {
foo : aSafeAsyncFunctionThatNeedsJQuery,
bar : iPromiseToEnsureJQueryIsLoadedBeforeCalling
};
}));
Enjoy,
-Abbey Hawk Sparrow