admin管理员组文章数量:1202391
Using YUICompressor I get the following error from my javascript code:
[ERROR] 270:201:missing name after . operator [ERROR] 292:6:missing ; before statement
Here's the javascript code at the following lines:
Line 270:
new _ow.getScript(_ow.wwwurl+'/widget/save?title='+encodeURIComponent(this.obj.title.value)+'&url='+encodeURIComponent(this.obj.url.value)+'&tags='+this.obj.tags.value+'&private='+this.obj.private.checked+'&c='+this.obj.notes.value+'&service='+services+'&token='+(_ow.token ? encodeURIComponent(_ow.token): ''), function(data) {
Line 292:
});
I can't figure out what the problem is since this Javascript code works fine on all browsers.
EDIT: I split the line in multiple lines and figured out that the "missing name after . operator" is generated by this code:
this.obj.private.checked
Is private a keyword that makes the YUI compressor go mad?
Using YUICompressor I get the following error from my javascript code:
[ERROR] 270:201:missing name after . operator [ERROR] 292:6:missing ; before statement
Here's the javascript code at the following lines:
Line 270:
new _ow.getScript(_ow.wwwurl+'/widget/save?title='+encodeURIComponent(this.obj.title.value)+'&url='+encodeURIComponent(this.obj.url.value)+'&tags='+this.obj.tags.value+'&private='+this.obj.private.checked+'&c='+this.obj.notes.value+'&service='+services+'&token='+(_ow.token ? encodeURIComponent(_ow.token): ''), function(data) {
Line 292:
});
I can't figure out what the problem is since this Javascript code works fine on all browsers.
EDIT: I split the line in multiple lines and figured out that the "missing name after . operator" is generated by this code:
this.obj.private.checked
Is private a keyword that makes the YUI compressor go mad?
Share Improve this question edited Dec 28, 2009 at 19:40 Andreas Bonini 44.7k31 gold badges124 silver badges158 bronze badges asked Jan 31, 2009 at 20:54 Luca MatteisLuca Matteis 29.3k22 gold badges116 silver badges171 bronze badges5 Answers
Reset to default 13private
is a reserved word.
First, I'd reformat the code to make it more readable:
new _ow.getScript(_ow.wwwurl
+ '/widget/save?title='
+ encodeURIComponent(this.obj.title.value)
+ '&url='
+ encodeURIComponent(this.obj.url.value)
+ '&tags='
+ this.obj.tags.value
+ '&private='
+ this.obj.private.checked
+ '&c='
+ this.obj.notes.value
+ '&service='
+ services
+ '&token='
+ (_ow.token
? encodeURIComponent(_ow.token)
: ''),
function(data) {
});
Then, the line # reported by the compressor should help you drill down on what the problem is.
Remeber to use option --type js ex.
yuicompressor --type js -o comressed.js filetocompress.js
you can download and install apache ant, download the yui source, edit the source code (in src folder, in the org and the com subfolders) to remove all references to the keyword blocking your progress (it goes quite fast, I edited about 3 to 4 files i think, had to run ant twice because the first time got a reference error, but all it took was deleting another line referring to the keyword) and once ant compiles successfully you have a brand new .jar and you can use this to compile your problematic js. did this with yuicompressor2-4.7 and the "import" keyword (used quite extensively in mozilla extension code)
You could make your own life a lot easier just by breaking it out onto multiple lines. You're compressing it anyway, so it's not like it's going to make a difference to the final size...
本文标签: yuiJavascript YUICompressor errorStack Overflow
版权声明:本文标题:yui - Javascript YUICompressor error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738649181a2104771.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论