-
Notifications
You must be signed in to change notification settings - Fork 778
Open
Labels
enhancementNew feature or requestNew feature or request
Description
In modern browsers, can we use a Proxy instead of hard coding all the element types?
I'm using this right now:
import { h } from "./lib/hyperapp.js";
const { main, h1, input, ul, li, button } = new Proxy(h, {
get(h, type) { return (props, children) => h(type, props, children) }
});One more line of code, and you have support for custom elements:
const { hyperApp } = new Proxy(h, {
get(h, type) {
const name = type.replace(/([A-Z])/g, c => "-" + c.toLowerCase());
return (props, children) => h(name, props, children)
}
});
console.log(hyperApp({foo:"bar"}, ["baz"])); // type: "hyper-app"Thoughts? :-)
merlinaudio
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request