first draft for LightningElement.CustomElement abstraction#7
first draft for LightningElement.CustomElement abstraction#7
Conversation
text/0000-custom-element.md
Outdated
|
|
||
| ```js | ||
| import XFoo from 'x/foo'; | ||
| customElements.define('x-foo', XFoo.CustomElement); |
There was a problem hiding this comment.
this is the meat of this proposal... the .CustomElement static accessor on every LWC constructor
There was a problem hiding this comment.
This would be quite verbose, but what do you think about 'CustomElementConstructor'?
There was a problem hiding this comment.
The main issue that I have with CustomElement, is that the custom element represents a custom element instance while the custom elements registry accepts a constructor. I support @apapko into making this explicit.
There was a problem hiding this comment.
I mentioned a similar concern in salesforce/lwc#1395 (review)
|
|
||
| # Summary | ||
|
|
||
| Facilitate the registration of LWC Constructor as Custom Elements. |
There was a problem hiding this comment.
registration of LWC Constructor as Custom Elements
text/0000-custom-element.md
Outdated
|
|
||
| # Motivation | ||
|
|
||
| As today, the way to generate a qualifying Custom Element from a LWC Constructor, is via an experimental API: `buildCustomElementConstructor()`. Since this is a primary use case for LWC, we want to make it more ergonomic, and simpler. Additionally, the experimental API allow you to generate more than one Custom Element per LWC Constructors, which does not align with the web components semantics. |
| # Motivation | ||
|
|
||
| As today, the way to generate a qualifying Custom Element from a LWC Constructor, is via an experimental API: `buildCustomElementConstructor()`. Since this is a primary use case for LWC, we want to make it more ergonomic, and simpler. Additionally, the experimental API allow you to generate more than one Custom Element per LWC Constructors, which does not align with the web components semantics. | ||
|
|
There was a problem hiding this comment.
Listing a use case would be useful
text/0000-custom-element.md
Outdated
|
|
||
| # Proposal | ||
|
|
||
| This proposal provides a high-level API (an abstraction layer) for authors to access the custom element associate to a LWC Constructor: |
There was a problem hiding this comment.
did you mean: associated with LWC Constructor?
text/0000-custom-element.md
Outdated
|
|
||
| ```js | ||
| import XFoo from 'x/foo'; | ||
| customElements.define('x-foo', XFoo.CustomElement); |
There was a problem hiding this comment.
This would be quite verbose, but what do you think about 'CustomElementConstructor'?
| This proposal provides a high-level API (an abstraction layer) for authors to access the custom element associate to a LWC Constructor: | ||
|
|
||
| ```js | ||
| import XFoo from 'x/foo'; |
There was a problem hiding this comment.
is allowing to import 'constructor' property an option?
import { constructor as XFooConstructor } from 'x/foo';| ## Semantics and Invariants | ||
|
|
||
| * There is a 1-1 mapping between LWC Constructors and the corresponding Custom Element. | ||
| * Claiming the Custom Element for the abstract `LightningElement` must be disallow. |
There was a problem hiding this comment.
what does this mean- Claiming the Custom Element for the abstract LightningElement?
text/0000-custom-element.md
Outdated
|
|
||
| ```js | ||
| import XFoo from 'x/foo'; | ||
| customElements.define('x-foo', XFoo.CustomElement); |
There was a problem hiding this comment.
The main issue that I have with CustomElement, is that the custom element represents a custom element instance while the custom elements registry accepts a constructor. I support @apapko into making this explicit.
|
Looking at this RFC again, I am now uncertain about attaching a We have started decoupling the LWC engine from the DOM (#23), what would the
|
|
This would be huge for nCino! We have a library of custom web components that we've built and use in many of our Salesforce applications. It would save us a lot of time and money if we could reuse them. |
|
@jodarove This was already implemented right? should we change the status then? |
|
thanks @pmdartus! |
) * first draft for LightningElement.CustomElement abstraction * update meta for rfc app * wip: change to CustomElementConstructor * wip: review comments * Update 0000-custom-element.md * Update RFC status Co-authored-by: Jose David Rodriguez Velasco <jodarove@gmail.com> Co-authored-by: Pierre-Marie Dartus <p.dartus@salesforce.com>
No description provided.