Compilation error caused by trailing commas in javascript - javascript

edit: I didn't make it clear. I'm using play framework.
I have compilation error as follows:
"Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer versions of JS, set the appropriate language_in option."
But I can't find such an option to change language options. How can I get rid of this compilation error?
I can't modify js file - it is generated and is huge. Also, I really don't care about IE8 and below.
It would be great if someone could help me.

Related

IE 8 issues (with js)

Is there a way to tell a page/project this it should ignore some javascript code/file? I am working on a project, that works well on all browsers, eccept IE8. I haven't tested for less than IE8, and I wont bother. Anyway. The error that I am getting is my language, but I'll translate to English.
Exception was thrown at line 4, column 12204 in https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
0x800a01b6 - A javascript runtime error occured: The object doesn't support the property or method 'getElementsByClassName'
If there is a handler for this exception, the program may be safely continued
This is just one of MANY errors like that.
And many more.
This is a huge problem for me. Is there any workaround for this? I am forced to keep this file, since the project is big, and other pages depend on this file
You could try replacing this line...
getElementsByClassName("classname")
with...
$(".classname")

IE not loading page with Javascript and Raphael

I'm testing out a website that runs fine on Firefox (Win/Mac), Chrome (Win/Mac) and Safari. I'm having difficulty with Internet Explorer unfortunately. I get the following error message:
SCRIPT65535: Unexpected call to method or property access.
raphael-min.js, line 8 character 64961
I've taken a look at the debug output which looks like just takes me to a part of the Raphel library:
c=a.getScreenCTM()||a.createSVGMatrix()
I've searched for this error message online, but I don't understand what solution is relevant to this case as I've no idea what is causing the problem. I am also using the jQuery library. Are there any tests that I can do that can give me more information about the source of the problem?
I just found how to patch this, in order to keep the compressed version of Raphael.
Replace (don't forget the coma):
c=a.getScreenCTM()||a.createSVGMatrix(),
By that (dont't forget the end space):
c;try{c=a.getScreenCTM()||a.createSVGMatrix()}catch(e){c=a.createSVGMatrix()};var
Works fine ! :)
Means :
c; : declaration of variable c, and stop the first instruction.
try{c=a.getScreenCTM()||a.createSVGMatrix()}catch(e){c=a.createSVGMatrix()}; : our instruction, surrounded by a try/catch, to avoid IE error
var + a space : (don't forget the space!) allow us to continue to declare variable
I found out that it's an issue with compression (of the js file). I had the exact same issue and I had been searching for a solution. Guess what? I tried it with the uncompressed Raphael file and voila! No more issues. Compressed file needs a tweak, it seems.

Type coercion bug in IE8 RegExp.exec()?

I don't know if this is a know problem in IE8, but I can't really find any info on it.
// The regex can vary but has to have a non-matching group defined:
var re = /^(\s)?[\d]+$/i;
// We call it with a string...
re.exec("2");
// We call it with a number...
re.exec(2);
Firefox and Chrome (can't try it in Opera right now) have no problem with either calls. But on IE8 the second call fails with an "Object does not support that property or method".
Is this a known bug or something?
I saw the same issues in an Ext JS 4 application. Lots of things were failing as Ext JS appears to pass numbers in the exec() method at times. The issue turned out to be a third party library SyntaxHighlighter. Removing this reverted the default IE8 behavior and re.exec(2); worked.
I'd suggest cutting down the external JS that you include in your app until you find the culprit.
Since exec takes a string I would make sure you are passing a string. By passing a number in I would say you are trying to count on grey areas of the way browsers implement javascript.

Why does jQuery 1.4.2 compressed have a syntax error?

I always have noticed this, including in versions before as well. About half way through jQuery's compressed version you'll see some regex:
[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^
The error appears to be at ['"]
I'm sure it's not really a syntax error, but all my code editors recognize it as one, which makes development a pain if I try to combine JavaScript files. Does anyone know what's going on here?
It's a character entity in a regular expression, as specified by the square brackets. There are no restrictions on quote characters in them. All that's going on is buggy syntax highlighting. Ask the developer of your editor.
your code editor sucks, this isnt a syntax error if its inside of a regex literal, which i suspect it is.
the code editor you use probably doesnt support regex literals properly, and that its a string , which would cause the error

jslint ignore Expected '{' errors

I have a lot of Expected '{' and instead saw 'blah' errors that spit out when I run my scripts through jslint. Is there an option that ignores this error?
There are no options to ignore this unless you edit the source of jslint and remove this particular warning. However, it is highly recommended not to ignore this rule.
no. crocky is a curmudgeon js nazi.;-) there is a vs addin on codeplex that i added an ignore feature to though. the addin is still kinda buggy but works well enough. I haven't been able to get contact with the owner to get on the project so havent put a lot more time into it. anyway see here and get the patch from the patches tab
Actually, with the latest version of sublime-jslint, I just told it to ignore these errors by adding to the "ignore_errors" option:
"ignore_errors":
[
"Expected '{' and instead saw"
],
Now whenever I run sublime-jslint on my files, I get:
jslint: ignored 5 errors.

Categories