by c-smile · 3y ago · 0 comments
<style>
div.beer {
prototype: Beer url(/components/beer.js);
}
</style>
<body>
<div class="beer" />
</body>
After that div.beer element will be instanceof Beer. In this case class Beer used as a [Web-alike] component.2. Your example would have atrocious load time implications for any non-trivial web page. Iterating the DOM through querySelectorAll to replace items at load time? Yikes!
So apparently with Sciter you can either have minimal code or acceptable performance. Got it. Would rather have my cake and eat it too.
CSS prototype property is a Sciter specific extension.
When the engine computes styles it does [if needed] this (pseudocode):
Object.setPrototypeOf(element, thatClass);
element.componentDidMount();
on applied elements.There is no "performance sacrifice" in case of handling prototype properties.
Prototypes are switchable if needed:
div.beer { prototype: Beer url(...); }
div.beer:hover { prototype: BeerHovered url(...); }"Those who do not learn from the past…"
element.selector {
prototype: ClassName url(in-module.js);
color: blue;
...
}
That above is significantly better than almost-dead-at-birth WebComponents: let customElementRegistry = window.customElements;
customElementRegistry.define('my-custom-element', MyCustomElement);
One simple CSS property instead of 20+ additional entities https://developer.mozilla.org/en-US/docs/Web/Web_ComponentsUsed quite a lot actually, on half of machines where Sciter is installed (~500..600 mln machines :)