Open
Description
I'm trying to create a web component using Surplus. The web component implements a render()
method that returns a DOM node created with Surplus. However, I am unable to access this
in certain situations because Surplus generates a bunch of IIFEs inside the render call.
Consider the following:
<button onClick={this.onClick}>Click me!</button>
The output of the code above is this:
(function () {
var __;
__ = createElement("button", null, null);
__.onclick = this.onClick;
__.textContent = "Click me!";
return __;
})()
Because of the surrounding anonymous function, this
is no longer the same as it was before, and thus I get an error (Cannot read property 'onClick' of undefined
).
Is it possible for the compiler to emit arrow functions instead of regular functions? Could that fix the issue?
Metadata
Assignees
Labels
No labels
Activity