-
Notifications
You must be signed in to change notification settings - Fork 12
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
WCCG in Declarative custom elements #32
Comments
it may be better to not imply a shadow root, i.e.: <template element="my-element" shadowroot="open"> or some such thing. otherwise it seems we'd be unable to register an element which has no shadow root. don't have a use case for having no SR off the top of my head, but i feel like someone might have a reason to |
Some discussion from the WCCG slack produced some ideas around syntax: <template element="has-open-shadow" shadowroot="open">...</template>
<template element="has-closed-shadow" shadowroot="closed">...</template>
<template element="has-light-only">...</template> Thanks @43081j or perhaps, per @EisenbergEffect <element tag="custom-element">
<template shadowroot="open">...</template>
</element> with maybe an extension to apply a javascript class: document.querySelector('element')
.define(class CustomElement extends HTMLElement {...}) We'd also like to make it clear that Declarative Custom Elements builds on Declarative Shadow DOM. They are not competitive proposals but complimentary. |
@EisenbergEffect , @bennypowers
<element tag="custom-element">
<a href="#">link 😃</a>
</element>
<custom-element><i>🍋</i></custom-element>
<element tag="custom-element">
<slot name="slot2"> 😃</slot>
<h2 slot="slot2" >heading 2 😌</h2>
</element>
<custom-element><i slot="slot2">🥕</i></custom-element>
<element tag="custom-element">
<template shadowroot="open">
<slot name="slot3"> 😃</slot>
</template>
<h3 slot="slot3">heading 3 😌</h3>
</element>
<custom-element><i slot="slot3">🥕</i></custom-element> The most natural interpretation is
|
Per the original strawman proposal, I'm not sure what would happen because the element definition only has behavior for the template and script tags. Here's a link to that strawman: https://github.com/WICG/webcomponents/blob/gh-pages/proposals/Declarative-Custom-Elements-Strawman.md I'd like to put together a new proposal based on my research, because the original proposal is very inadequate, but it's going to take some time because there are a huge amount of details that need to be worked through. |
would you mind to have a conversation on the high level goals of new proposal and scope? |
I think the strawman has mostly been ignored because folks realize it's too early to really do anything for declarative elements, since they are dependent on so many other features. I'm always open to discussion on high level goals, etc. It might be best to just create an issue like this one and list them out from your perspective. |
I want to point out that declarative custom elements and declarative shadow DOM have no relation, except that declarative custom elements must not use <element tag="custom-element">
<template shadowroot="open">...</template>
</element> This would attach a shadow root to that specific Likewise, this: <template element="has-open-shadow" shadowroot="open">...</template> would attach a shadow root to whatever the parent of that |
I wonder why this feature is being discussed here rather than in https://github.com/WICG/webcomponents? I don't think it's going to be great if we fork the venues for proposals. Are we expecting browser vendors to participate here as well, or develop some consensus opinion to bring to WICG? |
I guess it is question about priority. The declarative use of WC and around( custom elements, shadow root/template, binding, etc.) seems got enough attraction. The 5 years vision would include those features, disregarding of current maturity status. If you propose to move into WICG, it is expected that alignment on long term vision is in place and we are ready to work on details instead of just base principles. I am trying to keep my discussion points around principles and architectural parts, unfortunately it has to be accompanied with understandable samples. Which look like a proposal, but are not. At least not yet.
IMO the conceptual consensus has a sense to be shaped here first. And then could be exposed to vendors as part of review and vision. I would expect the vendors are more keen on discussions related to syntax and API, not a concepts to fit with each other. May be I am mistaken, did not have a chance to work on WICG level. For the user (not a vendor), the influence in discussions there do not expect to be fruitful. |
Correct, till the moment when slots become a part of declaration <element tag="custom-element">
<slot name="greet"> Hello </slot> World!
</element>
<custom-element><b slot="greet">👋</b></custom-element> Would you treat the content as a shadow-less template? That is where the DCE(here) and Declarative Shadow DOM meet. If the standard would make a decision to respect slots, it would be same as implementing light DOM version of I.e. we have 3 concepts overlapping semantically. Not necessary by syntax which yet to be defined. |
one more POC for DCE: |
DCE as alternative to TEMPLATE with
|
@sashafirsov There are some intersection semantics with https://github.com/rniwa/webcomponents/blob/add-dom-parts-proposal/proposals/DOM-Parts.md, specifically on the loops and attributes. If you need to stitch together the content that you want to pass down to a custom element as part of the light-dom, a template system is a lot more powerful that trying to open new APIs on custom elements directly. I'm also very much against opening new slotting mechanism for attributes, you can do that today by opening an attribute on the custom element itself, and observe that attribute to place the value in the right place inside your shadowRoot dom tree. cc @rniwa |
@caridy the Parts proposal covers only concept and API for parts implementation, not even JS but rather in browser engine level. Which is premature as the interface is not even defined. Here is a discussion on Declarative custom element syntax which (or proposals on declarative Template itself) meant to be the basis for referenced parts proposal. The closest statement for the connection between slots and parts is a single expression
The Parts proposal is baked in mind of few and there is no public forum to shape it up. As result it is not useful in any way. Only a good peace I was able to grasp from there is a curly braces
The SLOT, As stated, Declarative syntax has to be shaped first before going to low level implementation requirements which seems to happen with Parts. Here is a proposal for slots based HTML syntax. Please address its weak and strong sides. The JS/API are not relevant and should be shaped once the business requirements set. |
My AC for Declarative Custom Element:
"Any part" meant to be either
DCE also meant to work as a part of DCE collections(libs) and application, hence support
Note, the last item usually delegated to build toolchain. In Declarative Custom Element it has to be part of standard proposal as many DCE expected to have external dependencies and have to work natively in browser without dev toolchain. |
DCE PoC with template functionality for critique: https://github.com/EPA-WG/custom-element includes
Implementation as of now covers 1st half of AC ^^. |
The DX for DCE have jumped to another layer. Devtools plugin for POC now shows the template, data used for transformation, and their string presentation for step-by-step debugging of template. That is a must feature to be supported in browser if template is capable of working with complex data, or condition/loop/import other templates logic as in POC. Ideally the step-by-step debugging better to be supported by devtools itself. Looking how to achieve XSLT debug within browser. |
The Functionally complete declarative templating is the 1st in series of DCE proposals. It covers the template aspect. The Declarative Custom Element proposal which is more straight match to this discussion would follow. |
Hello, browsers already have two different kinds of declarative HTML templating (with XML syntax): |
Declarative custom elements - teaser
Not a proposal. Here we could outline the purpose and goals. WIGC proposal would follow.
Description
Defines the convention of defining the custom elements via HTML tags.
It is a part of declaratively defined functional web application running even with JS script disabled.
Links
Status
Initial API Summary/Quick API Proposal
Key Scenarios
Simple template use in custom element. The template DOM reuse for same kind of data presented multiple times in UI.
Extended use is a templates library to be reused across multiple pages. This feature requires external resource reference and include into page. Like HTML include.
Live POC for inline and external template library.
Concerns
Dissenting Opinion
Related Specs
Open Questions
follow up proposals
The text was updated successfully, but these errors were encountered: