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

window.toString overrides global toString #35

Open
Voxelot opened this issue Dec 11, 2014 · 0 comments
Open

window.toString overrides global toString #35

Voxelot opened this issue Dec 11, 2014 · 0 comments

Comments

@Voxelot
Copy link

Voxelot commented Dec 11, 2014

I'm currently in the process of porting env.js to Nashorn. While trying to run jQuery I discovered that the toString method in window.js (https://github.com/envjs/env-js/blob/master/envjs/window.js#L749) actually causes all objects to return '[Window]' when their toString method is called.

Chrome:


>toString()
"[object Window]"  
>toString.call("test")  
"[object String]"
>var a = {}
undefined
>a.toString()
"[object Object]"

Nashorn + env:


console.log(toString());
>>[Window]
console.log(toString.call("test"));
>>[Window]
var a = {};
console.log(a.toString());
>>[Window]

jQuery is unable to make ajax requests because the toString method is used when registering the transports (https://github.com/jquery/jquery/blob/master/src/ajax.js#L61). Since the toString method is broken, jQuery's "typeof" method will default to calling the transport functions objects which causes the "isFunction" check to fail, preventing any transports from being registered.

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

1 participant