google-closure

Suppressing or resolving compiler errors in goog.base

萝らか妹 提交于 2019-11-30 23:07:50
I use Closure Compiler on my sources and recently decided to enable the most strict mode via --jscomp_warning=reportUnknownTypes . Alas, it triggered a lot of warnings inside the goog.base itself! I've fixed all the problems in my own code and now I'm looking for a way to silence/remove errors in the closure library code. I tried to fix errors in base.js but quickly realized it's unfeasible. There are approximately 108 errors in the file and in most cases they are real errors because of goog.base doesn't care much about types: it's a common practice there to define a type like {?} or {*} . I

Http-Method changes from POST to OPTIONS when changing Content-Type

时间秒杀一切 提交于 2019-11-30 22:15:53
I am using closure library to do a simple POST. I think XhrIo should work because from my machine when I use any other rest client ,like Firefox browser app RESTClient or Chrome's Simple Rest Client , I can make POST request to the server and content type is application/json. But from my application I am unable to make a post. I am using the following code xhr = new goog.net.XhrIo; xhr.send('http://myhost:8181/customer/add','POST', goog.json.serialize(data)); If I leave the headers default, I get this Encoding: UTF-8 Http-Method: POST Content-Type: application/x-www-form-urlencoded;charset=UTF

Why does Google Closure swap arguments?

烈酒焚心 提交于 2019-11-30 20:16:58
I've seen the Google Closure compiler do a lot of rewriting in if-clauses. For example: if (a === 3) {…} turns to if (3 === a) {…} Are comparisons faster in JavaScript, if the primitive is the first argument, or what is the reason for this? Esailija From ReorderConstantExpression.java : /** * Reorder constant expression hoping for a better compression. * ex. x === 0 -> 0 === x * After reordering, expressions like 0 === x and 0 === y may have higher * compression together than their original counterparts. * */ As stated by a google closure compiler contributor , the compression the code

Suppressing or resolving compiler errors in goog.base

倾然丶 夕夏残阳落幕 提交于 2019-11-30 19:27:31
问题 I use Closure Compiler on my sources and recently decided to enable the most strict mode via --jscomp_warning=reportUnknownTypes . Alas, it triggered a lot of warnings inside the goog.base itself! I've fixed all the problems in my own code and now I'm looking for a way to silence/remove errors in the closure library code. I tried to fix errors in base.js but quickly realized it's unfeasible. There are approximately 108 errors in the file and in most cases they are real errors because of goog

Using Google Closure compiler [duplicate]

 ̄綄美尐妖づ 提交于 2019-11-30 15:03:15
Possible Duplicate: jQuery compiled with Google Closure Compiler I am using jQuery and I have all of my JS code in application.js file. When I compile "application.js" with the Google Closure compiler (using the advance options) I get a js file with no errors and warning. However, I am unable to use the file in my page, I get an error on page load which says "TypeError: Result of expression '$("div.tile").d' [undefined] is not a function." My question is can I compile a js file which uses jQuery? Yes, if you care to include the jQuery file in with your other file. Yes, if you use simple mode,

How to force google closure compiler to keep “use strict”; in the compiled js code?

孤者浪人 提交于 2019-11-30 11:21:18
问题 If you're using the module pattern and have something like this: (function () { "use strict"; // this function is strict... }()); and compile the code using the Google Closure Compiler, the "use strict"; directive will not make it into the compiled file. So how do you prevent the Closure Compiler from removing the ES5/strict directive? (Note that I don't want to use the other mode of enforcing ES5/strict mode, which is to simply add the "use strict"; to the first line of the compiled file. I

Why does Google Closure swap arguments?

吃可爱长大的小学妹 提交于 2019-11-30 04:22:25
问题 I've seen the Google Closure compiler do a lot of rewriting in if-clauses. For example: if (a === 3) {…} turns to if (3 === a) {…} Are comparisons faster in JavaScript, if the primitive is the first argument, or what is the reason for this? 回答1: From ReorderConstantExpression.java: /** * Reorder constant expression hoping for a better compression. * ex. x === 0 -> 0 === x * After reordering, expressions like 0 === x and 0 === y may have higher * compression together than their original

How to force google closure compiler to keep “use strict”; in the compiled js code?

孤街醉人 提交于 2019-11-29 23:54:08
If you're using the module pattern and have something like this: (function () { "use strict"; // this function is strict... }()); and compile the code using the Google Closure Compiler, the "use strict"; directive will not make it into the compiled file. So how do you prevent the Closure Compiler from removing the ES5/strict directive? (Note that I don't want to use the other mode of enforcing ES5/strict mode, which is to simply add the "use strict"; to the first line of the compiled file. I want to use the module pattern as described here .) This isn't the greatest answer, but as far as I can

Is there a way to generate Javascript API documentation like the Google Closure Library API Documentation?

青春壹個敷衍的年華 提交于 2019-11-29 20:57:32
I'm trying to find a tool that generates HTML documentation for my Javascript source code. Does anyone know if the tool that Google uses to generate the interface at the following URLs is open source? Would I be able to generate similar output? http://closure-library.googlecode.com/svn/docs/class_goog_proto2_Serializer.html http://closure-library.googlecode.com/svn/docs/namespace_goog_date.html http://closure-library.googlecode.com/svn/docs/namespace_goog_events.html http://closure-library.googlecode.com/svn/docs/class_goog_gears_Database.html http://closure-library.googlecode.com/svn/docs

Google Closure minifier online?

怎甘沉沦 提交于 2019-11-29 20:20:28
Has anyone setup an online copy/paste utility for Google's Closure minifier? I'm working on a project and I want to minify part of the code manually without having to setup the entire project on my own. How about google's own service: http://closure-compiler.appspot.com/home I should point out that "setting up the entire project on my own" really is not half as scary as you make it out to be :p. I mean, it's a matter of downloading a java.jar and running it. Instructions: Download at http://closure-compiler.googlecode.com/files/compiler-latest.zip Unzip run java command line: java -jar