[email protected]
This new version stabilizes the api by introducing various changes and tests to guarantee the future stability of Atomico.
Break!
custom Element
is replaced by the c
function.
the c
function is only limited just create the Element to be registered by customElements.define
, example:
import { h, c } from "atomico";
const MyComponent = () => <host />;
const HTMLMyComponent = c(MyComponent);
customElements.define("my-component", HTMLMyComponent);
This function also allows modifying the class to be used as the basis for the Atomico component, example:
const HTMLMyComponent = c(MyComponent, HTMLAnchorElement);
Improvements
Support is added to methods.
Using the host
tag you can define methods that work with the scope of the web component, example:
const MyComponent = () => {
const myMethod = () => console.log("hi!");
return <host myMethod={myMethod}>...</host>;
};
// After registration
let myComponent = document.querySelector("my-component");
await myComponent.updated;
myComponent.myMethod();
Security
- The nodes of the style tag are grouped and sanitized.
- The vdom nodes now have an origin marker to avoid injecting objects.
eate the Element to be registered bycustomElements.define
, example: