-
Notifications
You must be signed in to change notification settings - Fork 378
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
[declarative-custom-elements] shorter syntax #885
Comments
Neither of those options are feasible. In the first variant, you can't put the In the second variant, we really do need a What's wrong with the original example? Yes, there's an outer element, but it's all very explicit and follows expectations of how the elements already behave. |
I see what you mean. There's nothing wrong with it. I was only wondering if there's a less verbose way to do it. What if with <element name="percentage-bar" shadowmode="closed">
<div>...</div>
<style>/*...*/</style>
<script type=module>
export default class MyEl extends HTMLElement { /*...*/ }
</script>
</element> the script runs once, but all other content of the If we could do that, then we could also extend the functionality to the following. In one file, <div>...</div>
<style>/*...*/</style>
<script type=module>
export default class MyEl extends HTMLElement { /*...*/ }
</script> In another file that uses it: <element name="my-el" src="./my-el.html" /> which is appealing. In contrast, with the
<template>
<div>...</div>
<style>/*...*/</style>
</template>
<script type=module>
export default class MyEl extends HTMLElement { /*...*/ }
</script> and the consumer would be: <definition name="my-el" src="./my-el.html" /> Even if the original idea is the only way to do it, the name <element name="my-el">
<template>
<div>...</div>
<style>/*...*/</style>
</template>
<script type=module>
export default class MyEl extends HTMLElement { /*...*/ }
</script>
</element> I'm on the fence though. Regardless, writing "single-file elements" is gonna be neat. |
WCCG had their spring F2F in which this was discussed. You can read the full notes of the discussion (WCCG had their spring F2F) in which this was discussed, heading entitled "Declarative Templating & Custom Elements". This was briefly discussed as part of that topic. The consensus from present members of the WCCG was that more use cases need to be captured around this area, in order to clarify what these proposals solve. |
If we're going to add special attributes to
template
, likeshadowmode
which is specifically for custom elements (right?) then why not use template for the custom element definition without and extradefinition
element (less nesting)?F.e. instead of
We could write the following more simple version:
Would that be too conflicting with how
template
currently works?If it isn't feasible to use
template
that way for technical reasons of the browser (f.e. the parser implementation, or something), then what about something likeHmmm. 🤔, I really like the
<element>
naming. Perhaps all content inside<element>
, except for script tags, is treated the same as (or similar to) a<template>
?From a developer experience perspective, the less to write the better.
The text was updated successfully, but these errors were encountered: