jquery-with-dom

1.0.0 • Public • Published

jquery-with-dom.js

NPM version npm Travis

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

Readme

Keywords

Package Sidebar

Install

npm i jquery-with-dom

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • khrome