Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMD/UMD wrap-IIFE #14

Open
ctrlmaniac opened this issue Dec 5, 2016 · 2 comments
Open

AMD/UMD wrap-IIFE #14

ctrlmaniac opened this issue Dec 5, 2016 · 2 comments

Comments

@ctrlmaniac
Copy link
Contributor

Please, can you change the old jquery IIFE to the one provided by umdjs?

I dont' know coffeescript, otherwise I'd pull a request.

// Uses CommonJS, AMD or browser globals to create a jQuery plugin.

(function (factory) {
    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 ($) {
    $.fn.jqueryPlugin = function () { return true; };
}));
@ro31337
Copy link
Owner

ro31337 commented Dec 6, 2016

I probably can, can you please explain why? Thx

@ctrlmaniac
Copy link
Contributor Author

ctrlmaniac commented Dec 6, 2016 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants