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

issue with es6 classes #260

Open
k-yle opened this issue Sep 30, 2017 · 1 comment
Open

issue with es6 classes #260

k-yle opened this issue Sep 30, 2017 · 1 comment
Labels

Comments

@k-yle
Copy link

k-yle commented Sep 30, 2017

inputing:

function xhr(url, callback) {
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function () {
        if (this.readyState == 4 && this.status == 200)
            callback(JSON.parse(this.responseText));
    };
    xhr.open('GET', url, true);
    xhr.send();
}

results in:

class xhr {
    constructor(url, callback) {
        const xhr = new XMLHttpRequest();
        xhr.open('GET', url, true);
        xhr.send();
    }

    static onreadystatechange() {
        if (this.readyState == 4 && this.status == 200)
            callback(JSON.parse(this.responseText));
    }
}

because the function has the same name as a variable within the function.

@nene
Copy link
Collaborator

nene commented Sep 30, 2017

Thanks for reporting. That's definitely wrong result. The xhr() function should not have been transformed into class at all.

This again confirms that the current class transform implementation is fundamentally flawed.

@nene nene added the bug label Sep 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants