Custom method
DominicVonk opened this issue · comments
Hi
Can you add the custom function like in lighterhtml?
like uhtml-intents ? 🤔
This is my current implementation
import { custom } from "lighterhtml";
/**
*
* @param {any} Component
*/
export default function lighterhtml (Component) {
const { svg, html, render } = custom({
attribute (callback) {
return (node, name, original) => {
if (node instanceof Component && name !== "ref") {
return (value) => {
node._setProps({ [name]: value });
};
}
if (node instanceof Component && name === "ref") {
return (value) => {
callback.apply(this, [node, name, original])(value);
node.__ref = true;
if (node != value.current) {
node.forceUpdate();
}
};
}
if (node) {
return callback.apply(this, [node, name, original]);
}
return () => { }
};
},
});
return { svg, html, render };
}
beside suggesting to use callback.call(this, node, name, original)
instead of callback.apply(this, [node, name, original])
, to make GC life a tiny bit easier, the reason uhtml branched out lighterhtml is to provide the minimum amount of moving parts.
As both libraries basically work the same, and uhtml is just a subset of lighterhtml, why do you need to move from the more capable library to the less capable one? Once I implement this stuff the size will be nearly the same so I am not sure I am following your requirement here.
Thanks for clarification, but nope, this won't land in here as this project is minimalistic for a reason and uhtml-intents
as well as the fact holes can be functions so you can implement your behavior as you like, but replicating the extra lighterhtml has that I don't want in here is likely never going to happen.