Skip to content

window.toString overrides global toString #35

@Voxelot

Description

@Voxelot

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions