使用 fn.extend() 和 Google 闭包编译器扩展 jQuery
Extend jQuery with fn.extend() and Google closure compiler?
我正在尝试针对包含此扩展的代码运行Google闭包编译器:
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);
});
}
});
我得到命令行和警告:
# 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(){
^
有没有办法避免这个警告? this
显然不是全球this
.
jQuery代码一般与ADVANCED_OPTIMIZATIONS
不兼容。请参阅 https://stackoverflow.com/a/16463099/1211524
相关文章:
- 使用Google闭包编译器包含一个Ecmascript 6类
- 使用Google闭包编译器调试代码删除
- google闭包编译器、PRETTY_PRINT和object literal
- 闭包编译器--调试解决了我的错误
- 闭包编译器、主干和元编程
- 无法使用 ant 和闭包编译器编译 javascript,因为 Jquery 的 $ 是未声明的
- 为什么 Google 闭包编译器会重命名对象的属性名称
- 谷歌闭包编译器不压缩字符串值
- Google 闭包编译器和音频事件
- 如何在JavaScript中为Google闭包编译器设置参数类型
- 闭包编译器不支持ES6
- 闭包编译器高级和服务器端注入的Javascript
- 闭包编译器将't关闭可疑代码警告
- 谷歌闭包编译器,某些属性永远不会被重命名
- 用谷歌闭包编译器编译jQuery会产生Uncaught TypeError
- 什么是闭包编译器
- 闭包编译器无法读取目录
- 使用闭包编译器简单优化从函数内部删除调试代码
- 闭包编译器命令行没有'似乎不适用于最新版本
- 闭包编译器可以构建CommonJS模块