Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript YUICompressor error

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?

like image 779
Luca Matteis Avatar asked Jan 31 '09 20:01

Luca Matteis


2 Answers

private is a reserved word.

like image 116
Crescent Fresh Avatar answered Nov 05 '22 10:11

Crescent Fresh


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.

like image 25
Ates Goral Avatar answered Nov 05 '22 11:11

Ates Goral