0

I am trying to run the Google closure compiler against code that includes this extension:

jQuery.fn.extend({
    /** \brief Apply the makeButton() function to a jQuery() object.
     *
     * This function calls our snapwebsites.Output.makeButton() function
     * on all the objects in this jQuery and returns the necessary reference
     * to continue the jQuery chain.
     *
     * We use this function when we setup a click() handler on a button,
     * for example:
     *
     * \code
     *    jQuery(".add-user-button")
     *      .makeButton()
     *      .focus()
     *      .click(function(e)
     *          {
     *              ...snip...
     *          });
     * \endcode
     *
     * This gives users the possibility to use Enter, Space, or Click
     * with the Mouse on that button.
     */
    makeButton: function()
    {
        return this.each(function(){
                snapwebsites.Output.makeButton(this);
            });
    }
});

There is the command line and warning I get:

# The command line is one single line, broken up here for display
java -jar ../tmp/google-js-compiler/compiler.jar --js_output_file
     .../snapwebsites/BUILD/snapwebsites/analysis/js-compile/server-access.min.js
     --warning_level VERBOSE --compilation_level ADVANCED_OPTIMIZATIONS
     --externs .../snapwebsites/tmp/google-js-compiler/closure-compiler/contrib/
               externs/jquery-1.9.js
     --externs plugins/output/externs/jquery-extensions.js
     --js plugins/output/output.js --js plugins/server_access/server-access.js

plugins/output/output.js:925: WARNING - dangerous use of the global this object
       return this.each(function(){
              ^

Would there be a way to avoid this warning? this is clearly not the global this.

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
  • possible duplicate of [WARNING - dangerous use of the global this object](http://stackoverflow.com/questions/4036949/warning-dangerous-use-of-the-global-this-object) – Alexis Wilke Nov 27 '14 at 04:23

1 Answers1

0

jQuery code in general is not compatible with ADVANCED_OPTIMIZATIONS. See https://stackoverflow.com/a/16463099/1211524

Community
  • 1
  • 1
Chad Killingsworth
  • 14,360
  • 2
  • 34
  • 57
  • Ah... It seems to work with the jQuery externs offered by default with the closure compiler. But I guess that's because those are just plain definitions. It is cool though that you provide some form of compatible versions. – Alexis Wilke Dec 03 '14 at 04:09