Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regexES51ReservedWords added to js test #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

regexES51ReservedWords added to js test #15

wants to merge 1 commit into from

Conversation

zsitro
Copy link

@zsitro zsitro commented Sep 26, 2012

I can complete the list with over 20-50 reserved words (missing from the list) if this pull request passes...

Greets,
Zsitro

@mathiasbynens
Copy link
Owner

While it’s a good idea not to use these identifiers as global variable names in browser environments, they’re not prohibited by the spec (which is what this tool checks for). They’re not listed in http://ecma-international.org/ecma-262/5.1/#sec-7.6.1, so I don’t think they should be added here.

That said, I’d be interested in seeing your full list.

@zsitro
Copy link
Author

zsitro commented Sep 26, 2012

If you use "self" for example in IE to declare a variable, your script will fail with "Not Implemented" error. That's a very strong reason why it's NOT a proper variable name.

http://zsitro.com/self-is-a-protected-namespace-in-ie-avoid-using-it-as-a-local-variable-name/

I suggest to add a new regex group with "avoid" status.
I can try to implement it...

@mathiasbynens
Copy link
Owner

Interesting. Which version(s) of IE does this apply to? Is there an online test case to reproduce the issue? Are you sure this is not simply because you forgot to use var before self?

@zsitro
Copy link
Author

zsitro commented Sep 26, 2012

Here you go: http://jsbin.com/irikus/5 The message will be alerted in IE.

@mathiasbynens
Copy link
Owner

Which IE version(s)? Are you sure this is not simply because you forgot to use var before self?

@zsitro
Copy link
Author

zsitro commented Sep 26, 2012

All IEs! Take a look at this example: http://jsbin.com/irikus/7/ Here I do not use var before variable name, because $(document).ready(function( will expose them to the global window scope. So the expected behavior would be:

first button click => alerts 1
second button click => alerts 2

And that's what happens in every browser except in ie. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants