-
Notifications
You must be signed in to change notification settings - Fork 386
Open
Description
At the Spring 2023 F2F we talked about the need to discover all the open questions and dependencies on other specs that declarative custom elements have, in order to use declarative custom elements to help discover, prioritize other work.
Here are some questions and spec dependencies I can think of:
Questions
- Declaration
- How are attributes and properties declared?
- How are attributes reflected to properties? Do attributes have converters for numbers, boolean, enums, etc?
- How are styles declared?
- Are they part of the template or can they be shared and adopted?
- Can they be external? Or bundled and referenced from a nested sheet?
- Are registrations always global, or can they be scoped?
- If scoped, does the declaration establish an id that can be used to define the element in a scope?
- If scoped, do we need a way to define all the child definitions that might be used?
- How do you set ShadowRootInit options like mode and delegates focus?
- How are attributes and properties declared?
- Scripting
- Do declarative custom elements run with JavaScript disabled?
- Will HTML Modules be importable from HTML with JavaScript disabled?
- What is the base class for a declarative custom element? Does it directly extend HTMLElement, or is there another class with shared behavior?
- Can a declarative custom element be enhanced with script?
- How is that script associated with the element?
- Must the script be inline, or can it be bundled?
- Can the script be loaded late? Is there an upgrade-like step when it does?
- Lifecycle
- How do elements detect changes to data?
- When do element re-render? Synchronously or asynchronously?
- If synchronously, how do you handle data-consistency? ie
<img src="/avatars/{{lastName}}/{{firstName}}.jpg">
will make erroneous requests iffirstName
andlastName
are set at the same time. - If asynchronous, on what timing? Microtask? Is there an API for waiting for an element to update?
- If synchronously, how do you handle data-consistency? ie
- Templates
- What are the semantics of template updates?
- Is static DOM guaranteed to not be updated when re-rendering the same template?
- Are bindings dirty-checked?
- If so, do we need an opt-out for binding to stateful properties like
input.value
?
- If so, do we need an opt-out for binding to stateful properties like
- If a new template (ie from a different branch in a conditional) is rendered, does it clear the existing DOM?
- How are event listeners added in templates?
- Do event listeners make sense in declarative custom elements? What kinds of things could they do declaratively ? Fire another event? Assign a property?
- Or does event handling require augmenting declarative definitions with script?
- How are properties set on elements in templates?
- How do you set
mixedCase
property names?
- How do you set
- How are conditional and looping handled in templates?
- Is there a keyed looping construct that reorders DOM?
- Can templates be shared? Is there a sub-template "call" operation and a named template declaration?
- What is the expression language for bindings? Is it a subset of JS?
- Does it support literals? Array literals?
- Does it support optional-chaining and nullish coalescing?
- Can expressions contain method calls? If not, does the scope for expressions need a wrapper over some of the DOM to turn methods into getters? (ie
this.getAttribute('name')
->this.attributes.name
)
- What is the data model available to to expressions?
- Is the scope something like class scope where you have the globals and
this
?
- Is the scope something like class scope where you have the globals and
- What happens if expressions throw?
- Is there a way to remove an attribute that has bindings? ie
<img src="/foo/{{bar}}.jpg">
whenbar
is null
- What are the semantics of template updates?
- Security
- Do declarative custom elements introduce a script gadget vulnerability?
- Do they only run when script would have run? ie, not from innerHTML?
- Are they inline script for CSP?
- Do they support nonces?
- Is expression evaluation sanitized?
- Do we denylist things like
window.location
which can be used to exfiltrate data in bindings? - Do we denylist the Function constructor which can be used to eval code?
- Do we denylist things like
- Are bindings in text positions always escaped?
- If so, is there an unsafe operation for inserting HTML as a string?
- Can bindings to attributes do contextual autoescaping? (disallow
onclick="javascript:..."
)
- Do declarative custom elements introduce a script gadget vulnerability?
- Can ElementInternals properties be set?
- How do you define ARIA properties?
- How can an element be a FACE?
- How can ARIA associations be made across children shadow boundaries?
- SSR
- How do declarative elements handle an existing shadow root from declarative shadow DOM (hydration)?
- Do we need a deferred hydration system to ensure top-down initialization?
- Depending on how template updates work, do we need a system for marking what template SSR'ed a chunk of DOM so that we can perform an update on hydration instead of a replace?
I'm sure there are many more questions than this, of course.
Probable Spec Dependencies
- DOM Parts
- Template Instation
- Expressions
- Declarative ARIA
- Hydration
- Declarative CSS Modules
- ...
Use cases
Many of these questions need to be driven from use cases. We'll need to know what kind of elements we're trying to allow to be built. One of the most import questions there whether interactive elements are in scope. For example, can you build the basic counter element that's a common framework example? That alone requires event listeners and self-updating state.
EisenbergEffect, bahrus, renoirb, EllyLoel, zachleat and 15 morejimmyfrasche, EllyLoel, zachleat, cdata, sashafirsov and 4 more
Metadata
Metadata
Assignees
Labels
No labels