Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Setting Symbol.species should change the return value of constructor #239

Open
RuralHunter opened this issue Sep 29, 2020 · 3 comments
Open
Labels
js-engine Issues related to the js engine

Comments

@RuralHunter
Copy link
Contributor

According the spec, if Symbol.species is set, the return value of constructor should be the value of Symbol.species. It seems rhino doesn't do this.

Test case:

            var emptyFunc=function() {};
            var p = Promise.resolve(1);
            p.constructor = {};
            var pt1=p.then(emptyFunc);
            console.log('pt1='+pt1);

            var t = function(e) {
                e(emptyFunc, emptyFunc);
            };
            p.constructor[Symbol.species] = t;
            var pt2=p.then(emptyFunc);
            console.log('pt2='+pt2);
            console.log(pt2 instanceof t);

In htmlunit the output is:

pt1=[object Promise]
pt2=[object Promise]
false

In real browser such as chrome, the output is:

pt1=[object Promise]
pt2=[object Object]
true
@RuralHunter RuralHunter changed the title Symbol.species should change the return value of constructor Setting Symbol.species should change the return value of constructor Sep 29, 2020
@RuralHunter
Copy link
Contributor Author

This maybe can be handled in Promise. The use cases of Symbol.species is here

@RuralHunter
Copy link
Contributor Author

@rbri
Copy link
Member

rbri commented Mar 27, 2024

see #755

@rbri rbri added the js-engine Issues related to the js engine label Mar 27, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
js-engine Issues related to the js engine
Projects
None yet
Development

No branches or pull requests

2 participants