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

super() does not work in playground #6

Open
rad-pat opened this issue Mar 29, 2023 · 6 comments
Open

super() does not work in playground #6

rad-pat opened this issue Mar 29, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@rad-pat
Copy link

rad-pat commented Mar 29, 2023

As an example, take the TreeVritual demo from DemoBrowser https://qooxdoo.org/qxl.demobrowser/#treevirtual~TreeVirtual.html and click on the "To Playground" button. The playground will not run the code sample because of the super().main();. Replacing this with this.base(arguments); and the code sample runs ok again.

@goldim goldim added the bug Something isn't working label Apr 17, 2023
@goldim
Copy link

goldim commented Apr 17, 2023

@rad-pat Could you support a PR?

@rad-pat
Copy link
Author

rad-pat commented Apr 19, 2023

Yes, perhaps. I'm not really sure where this would need fixing though.

@goldim
Copy link

goldim commented Apr 19, 2023

I think a place where allowed words described maybe via array.

@hkollmann
Copy link
Member

Super can not be run in playground. Super() is exchanged by the Compiler with some base call. Playground code is not compiled.

@derrell
Copy link
Member

derrell commented Apr 19, 2023

It'd be worth asking @johnspackman whether there is a simple RegEx that could do the translation, or if it's far more complicated than that.

@level420
Copy link
Member

level420 commented Apr 21, 2023

as there is no way to have super working with non ES5 classes, it could be helpful to use the following code to partly emulate super:

function SUPER(instance) {
    return new Proxy(instance, {
        get(target, prop) {
            return Object.getPrototypeOf(Object.getPrototypeOf(target))[prop].bind(target);
        }
    });
}

(taken from here: https://stackoverflow.com/a/53802461)
Having SUPER in place in the playground a simple replacemant could be done. Instead of writing:

super().main()

we could write

SUPER(this).main()

Just something which I came across recently during javascript investigations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants