-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplified custom element definition #1064
Comments
Related WIP HTML Modules and Declarative Custom Elements Proposal Idea: https://gist.github.com/EisenbergEffect/8ec5eaf93283fb5651196e0fdf304555 |
<define name="my-counter" attributes="initial">
<template shadowrootmode="open"> One nit, this |
It's cool to see even more approaches to this! We reviewed a handful of different approaches to "declarative web components" at the Web Components Community Group in the spring. It would be great to get your thoughts on the various discussions available here. If you're interested, the community chats in Discord and meets on close to a monthly basis at meetings tracked on this calendar. We'd love to have your voice included in the conversation! |
@EisenbergEffect Very solid proposal Rob! Any chance you can make the compiler public? |
@MrHBS Thank you! I would like to make it all public. I need to find a way to get funded to work on it though. Maintaining it and managing the community would be a fulltime job. So, I've been hesitant to make it public without a real plan there. If you know of any companies that would be interested, please send them my way. |
Okay, I took all my (extremely rough) notes from my phone and translated it into a navigable repo, for my idea of CSS instancing and CSS-based templating: https://github.com/dead-claudia/css-web-components-idea Apologies in advance, there's zero WebIDL and zero polyfills there. (It'd be an extremely tricky polyfill, anyways.) |
Currently, classes have to manage a bunch of explicit wiring that has to be done almost every time. This could all be simplified a lot, to a module that doesn't need to do nearly as much.
The
<define>
element would accept four attributes:name
: the tag nameextends
: the builtin it extends (if applicable)attributes
: the observed attributesformassociated
: whether this is form-associated (boolean)Its children consist of zero or more of the following:
<template>
. If missing, it defaults to what's in its shadow root, replicating the shadow root options in its instances. This is cloned per-instance and used as the instances' children.<style>
or<link rel="stylesheet">
. This is adopted into the shadow root without cloning.<script type="module">
. This has a singledefault
export that initializes the instance state, receiving a shadow root and a signal (aborted on any reset). The shadow root would also receive all custom element lifecycle updates as events.State reset can be done via
elem.reset()
, and is done automatically on form reset.Form controls get
elem.form
and an implicitly handledfor
attribute to help simplify everything.It'd also be nice to see
customElements.define
extended to likewise support such a simplified definition:The text was updated successfully, but these errors were encountered: