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

The “arguments” object detection causes problems #8

Open
dmajda opened this issue Nov 20, 2015 · 0 comments
Open

The “arguments” object detection causes problems #8

dmajda opened this issue Nov 20, 2015 · 0 comments

Comments

@dmajda
Copy link

dmajda commented Nov 20, 2015

Inside the typeOf function, the arguments object is detected using the callee property:

if ( 'callee' in obj )
  // Opera: Object.prototype.toString.call(arguments) == 'Object' :(

This creates a problem in at least two situations:

  1. When dealing with regular objects containing the callee property, such as AST nodes resulting from parsing JavaScript by a parser conforming to Mozilla SpiderMonkey Parser API (or its successor, The ESTree Spec).
  2. In JavaScript strict mode, which defines (5.1, 6.0) the callee getter to throw an exception. This can be demonstrated e.g. using this code in recent Chrome: (function() { "use strict"; arguments.callee; })();).

The first case frequently bites users of the online editor at PEG.js website.

Since Object.prorotype.toString called on an arguments object returns [object Arguments] on recent versions of all common browsers (including Opera mentioned in a comment in jsDump code), I think it would be better to rewrite the detection to use it to detect arguments instead of the callee property.

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 a pull request may close this issue.

1 participant