-
Notifications
You must be signed in to change notification settings - Fork 26
RFC: lwc:dom directive reform
#17
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
Open
caridy
wants to merge
3
commits into
master
Choose a base branch
from
caridy/dom-directive-reform
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| - Start Date: 2019-10-28 | ||
| - RFC PR: (leave this empty) | ||
| - Lightning Web Component Issue: (leave this empty) | ||
|
|
||
| # Summary | ||
|
|
||
| This RFC describes the formalization of the `lwc:dom` directive in LWC Templates. Specifically, it defines how to lift existing restrictions on `lwc:dom="manual"` and introduces `lwc:dom="synthetic-portal"` as a way to support legacy systems. | ||
|
|
||
| # Basic example | ||
|
|
||
| This RFC lift some restrictions on the existing implementation and introduces the concept of `synthetic-portal`: | ||
|
|
||
| ```HTML | ||
| <template> | ||
|
|
||
| <h1>Existing feature (for leaf element only):</h1> | ||
| <div lwc:dom="manual"></div> | ||
|
|
||
| <h1>Lifting restrictions on existing feature:</h1> | ||
| <div lwc:dom="manual"> | ||
| <p>can have child elements in template to be combined with manually inserted nodes</p> | ||
| </div> | ||
|
|
||
| <h1>Introducing new feature (for leaf element only):</h1> | ||
| <div lwc:dom="synthetic-portal"></div> | ||
|
|
||
| </template> | ||
| ``` | ||
|
|
||
| # Motivation | ||
|
|
||
| There are 3 main motivations for this reform: | ||
|
|
||
| 1. The existing restriction that only leaf elements can be marked with `lwc:dom="manual"` is limiting. There are valid use-cases that requires a mix of elements generated from a template plus manually inserted elements, one of them is the use of a graph library that can connect elements (visually) where the elements are controlled via the template declarative mechanism, while the edges are manually generated and inserted by a 3rd party library. | ||
|
|
||
| 2. Legacy systems, specifically flexipages in Aura applications, are in needs to support rendering legacy DOM structures that are not suitable, or were not designed, to work inside a `ShadowRoot` instance. In such cases, it is imperative that from the perspective of those elements, they should behave as inserted in the document. | ||
|
||
|
|
||
| 3. The formalization of this feature can lead to performance improvements, specifically, the considerations with respect to what elements need to be keyed, and which one can be safely ignored. | ||
|
|
||
| # Detailed design | ||
|
|
||
| TBD | ||
|
|
||
| # Drawbacks | ||
|
|
||
| Why should we *not* do this? Please consider: | ||
|
|
||
| - `lwc:dom="manual"` is simply a no-op when using native shadow, but `lwc:dom="synthetic-portal"` does not work when using native shadow, that difference could be misleading. | ||
| - `lwc:dom="synthetic-portal"` is not getting us closer to use native shadow, in fact it could derail us from ever activating native shadow because features will be built on top of a feature that will never work in native shadow. | ||
|
|
||
| # Alternatives | ||
|
|
||
| No apparent alternative has been identified. | ||
|
|
||
| # Adoption strategy | ||
|
|
||
| If we implement this proposal, how will existing Lightning Web Components developers adopt it? Is | ||
| this a breaking change? Can we write a codemod? Should we coordinate with | ||
| other projects or libraries? | ||
|
|
||
| # How we teach this | ||
|
|
||
| The restriction of `lwc:dom="manual"` that will be lifted do not require a change in the mental model on how this feature is used. No side-effects were identified when combining declarative and manual elements. The only thing needed is to update the documentation to remove the restriction, and maybe adding an example that showcases the combination of declarative and manual elements. | ||
|
|
||
| On the other hand, the `lwc:dom="synthetic-portal"` must be documented, and probably gated. | ||
|
|
||
| # Unresolved questions | ||
|
|
||
| * Should `lwc:dom="synthetic-portal"` be gated or restricted for very specific cases? | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The proposal doesn't provide details about
syntehtic-portal? What are the intended use cases, and the expected behviors?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:) it is WIP, you are not supposed to be reviewing it yet... jajaja... let me finish this today.