javascriptdojodgrid

JavaScript keyword used as function in Dojo build


I am trying to build my project using Dojo version 1.9 with the closure compiler. In my project I am using dgrid version 1.1, and defined an extension for column filtering. When building the project, closure complains about using the JavaScript in keyword as function:

dojo.js.uncompressed.js:24719: ERROR - Parse error. missing name after . operator
                filter = filter.in(column, columnsList);

I also had the same issue with the class keyword, when defining css classes in JavaScript, but I enclosed it in quotation marks.

Is there any way to solve this issue ?


Solution

  • That's perfectly valid JavaScript. Keywords (and other reserved words) are allowed as property names when the context is clear, as it is there.¹

    You could work around CC's issue with it the same way you did in your own code, though its unpleasant to have to go re-fix it every time you upgrade Dojo:

    filter = filter["in"](column, filtersWithEmpty);
    

    ¹ This was a change in ES5 in 2009. Specifically, in property accessor expressions, IdentifierName was allowed where in ES3 (there was no ES4) it had to ben an Identifier (where Identifier is defined as IdentifierName but not ReservedWord; so class and in and such don't match Identifier, but do match IdentifierName).