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

Array.of() fails in browser when used in combination with prototypejs #2

Closed
dertseha opened this issue Aug 19, 2012 · 1 comment
Closed

Comments

@dertseha
Copy link

prototypejs (http://prototypejs.org/) has an own implementation of Array.prototype.reverse:

  function reverse(inline) {
    return (inline === false ? this.toArray() : this)._reverse();
  }

with _reverse pointing to the original implementation.

Array.of() calls

var args = Array.prototype.reverse.call(arguments)

but arguments is not an object of type Array, thus doesn't have the _reverse method - and fails.

For a test, modified the minified version of js-schema to call

Array.prototype.slice.call(arguments).reverse()

and it worked. (as per http://www.sitepoint.com/arguments-a-javascript-oddity/ : "Convert it to a real Array")

I didn't check other uses or similar constructs, but so far the scripts of my site run again.
Side question: How do you create the minified version before doing a commit?

@molnarg
Copy link
Owner

molnarg commented Aug 19, 2012

Thanks for the detailed description of this bug! I just committed the fix. It affected the String.of extension as well.

Regarding the build process: I added a build script to the root of the repository, and a section about it in the README!

Btw. I usually don't build the project every time I commit, because the testing is done in node.js.

Have a nice day :)

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

No branches or pull requests

2 participants