Open brodycj opened 6 years ago
Also any ideas for higher level app components analogous to https://github.com/lastmjs/redux-store-element?
I have to admit that I haven't explored web components beyond some tinkering. At a first glance, I think they'll integrate reasonably easily with Surplus since Surplus creates native DOM nodes (no middle layer to negotiate). Right now I'm mostly working on solidifying SVG support but hope to look at web components after that.
https://github.com/webcomponents/custom-elements-everywhere is good for testing.
Thanks Ismail, that looks super useful!
I cloned custom-elements-everywhere and added a surplus implementation. It shook loose one bug in surplus' codegen: we created bad identifiers for custom elements that had two dashes in their names due to a regex bug. After fixing that, surplus passes all of their "basic" web component tests. It fails some advanced ones because there's no framework support for declaratively subscribing to custom events. I.e., right now when you do <div onclick={...}></div>
, the onclick
parameter is no different from any property: you're just setting the .onclick
property of the div
. But that mechanism doesn't work for custom elements, as there's no .onMySpecialEvent
property.
I could add compiler support to convert setting .onclick
to node.addEventListener('click', ...)
, but I have to think about if that's a good idea. I wouldn't want to slow down the common cases to accomodate the corner case of custom events.
I resurrected a small utility for doing declarative custom event binding: https://github.com/adamhaile/surplus-mixin-on . It uses addEventListener()
under the hood instead of the DOM node.on...
properties. With it, Surplus gets a 100% score in custom-elements-everywhere tests on both Chrome and Firefox.
💯
It's nice not to lose speed. We are waiting it in the https://github.com/webcomponents/custom-elements-everywhere/tree/master/libraries
Really awesome, thanks guys!
Submitted a PR to add Surplus to custom-elements-everywhere: https://github.com/webcomponents/custom-elements-everywhere/pull/231
I am curious if anyone thought about how this wonderful library might be used with custom elements, etc. I am thinking in comparison to react, as in a few articles I found: