soscripted / sox

Stack Overflow Extras: a userscript for the Stack Exchange websites to add a bunch of optional toggle-able features
http://stackapps.com/q/6091/
MIT License
72 stars 15 forks source link

Function openImagesAsModals isn't properly quoted #417

Closed double-beep closed 5 years ago

double-beep commented 5 years ago

I recently saw the new feature Open as modals, but I realized that some reversed keywords aren't quoted at all, like css, id, etc. This can lead to "Unexpected identifier" errors.

To make it compatible with older versions of browsers, is it possible to fix that?

shu8 commented 5 years ago

@double-beep Thanks for the bug report!

Do you mean the keys for the object properties themselves should be quoted? I wasn't aware this was incompatible with some browsers if so! Please could you post your browser/platform so I can try an reproduce it and confirm if the fix works? :)

double-beep commented 5 years ago

Yes, the keys should be quoted. Some are reversed keywords in IE-like browsers and are likely to cause this error:

Syntax error @ "Stack Overflow Extras (SOX)"!
##########################
JSHINT output:
##########################

SyntaxError: Expected identifier, string or number
   at C.E_c (Unknown script code:3:391)
   at ja (Function code:62:80)
   at create (Function code:73:419)
   at e (Function code:14:351)

While I am using Chrome, this is only at home. At work, I have to use ME, v44.17763.1.0

This is kinda interesting.

shu8 commented 5 years ago

Thanks for clarifying!

Turns out Edge doesn't support the spread operator in object literals yet :(

Fixed in dev 2.5.19 though! :)