0

Possible Duplicate:
Google Closure Compiler parse error: invalid property id for css({float:'left'})

I tried to use closure compiler from

http://closure-compiler.appspot.com/home

to compile code

// ==ClosureCompiler==
// @output_file_name default.js
// @compilation_level ADVANCED_OPTIMIZATIONS
// ==/ClosureCompiler==

css({ float: 'left' })

but got error

JSC_PARSE_ERROR: Parse error. invalid property id at line 1 character 6
css({ float: 'left' })

How to fix it? This code is used in Oleg jqGrid createContexMenuFromNavigatorButtons method posted in stackoverflow answer.

Community
  • 1
  • 1
Andrus
  • 26,339
  • 60
  • 204
  • 378
  • Possible duplicate: [Google Closure Compiler parse error: invalid property id for `css({float:'left'})`](http://stackoverflow.com/q/6611867/1164465) – Christopher Peisert Sep 23 '12 at 18:46
  • 2
    Closure Compiler FAQ: **[I get "invalid property id" errors. But it works on Firefox!](https://code.google.com/p/closure-compiler/wiki/FAQ#I_get_"invalid_property_id"_errors._But_it_works_on_Fi)** – John Sep 24 '12 at 04:12

1 Answers1

3

float is likely to be recognized as a reserved word (although it isn't, it was in ES3), so it should be safe to use

css({ "float": "left"})
Bergi
  • 630,263
  • 148
  • 957
  • 1,375
  • It is a reserved word in EcmaScript 3 which is the standard version of JavaScript supported by IE8 and below. As stated in the Closure Compiler FAQ, you can avoid this warning by specifically stating you are targeting EcmaScript 5 (Internet Explorer 9 era and newer browsers) – John Apr 21 '14 at 17:26
  • @John: thanks for the hint! I added a link to the reference :-) – Bergi Apr 21 '14 at 18:59