qooxdoo / qxl.playground

The qooxdoo playground
http://qooxdoo.org/qxl.playground
2 stars 1 forks source link

super() does not work in playground #6

Open rad-pat opened 1 year ago

rad-pat commented 1 year ago

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 commented 1 year ago

@rad-pat Could you support a PR?

rad-pat commented 1 year ago

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

goldim commented 1 year ago

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

hkollmann commented 1 year ago

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

derrell commented 1 year ago

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 commented 1 year ago

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.