Javascript YUICompressor 错误

发布于 2024-07-12 22:45:19 字数 887 浏览 4 评论 0原文

使用 YUICompressor 我从我的 javascript 代码中得到以下错误:

    [ERROR] 270:201:missing name after . operator
    [ERROR] 292:6:missing ; before statement

以下是以下几行的 javascript 代码:

第 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) {

第 292 行:

});

我无法弄清楚问题是什么,因为此 Javascript 代码在所有浏览器上都能正常工作。


编辑:我将该行分成多行,并发现“. 运算符后缺少名称”是由以下代码生成的:

this.obj.private.checked

Is private a keywords that make the YUI compressor发疯?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

谁的年少不轻狂 2024-07-19 22:45:20

首先,我将重新格式化代码以使其更具可读性:

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) {
    });

然后,压缩器报告的行 # 应该可以帮助您深入了解问题所在。

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.

我爱人 2024-07-19 22:45:20

请记住使用选项 --type js ex。

yuicompressor --type js -o comressed.js filetocompress.js

Remeber to use option --type js ex.

yuicompressor --type js -o comressed.js filetocompress.js
触ぅ动初心 2024-07-19 22:45:20

您可以下载并安装 apache ant,下载 yui 源代码,编辑源代码(在 src 文件夹中,在 org 和 com 子文件夹中)以删除对阻碍您进度的关键字的所有引用(速度非常快,我编辑了大约 3 个我认为到 4 个文件,必须运行 ant 两次,因为第一次出现引用错误,但所需要的只是删除引用关键字的另一行),一旦 ant 成功编译,您就有了一个全新的 .jar,您可以使用它编译有问题的js。 使用 yuicompressor2-4.7 和“import”关键字(在 mozilla 扩展代码中广泛使用)来完成此操作

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)

一笑百媚生 2024-07-19 22:45:20

只需将其分成多行,您就可以使自己的生活变得更加轻松。 无论如何你都会压缩它,所以它不会对最终大小产生影响......

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文