-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[feature] Dynamic elements implementation <svelte:element> #6898
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
Merged
dummdidumm
merged 73 commits into
sveltejs:master
from
baseballyama:dynamic-elements-implementation
Apr 8, 2022
Merged
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit
Hold shift + click to select a range
f001107
Implement svelte:element for dynamically setting HTML DOM type
4fcc681
Add add_css_class method to DynamicElement
54e1c23
Reuse DOM elements if possible. Add dev warnings when passing nullish…
392bdc6
Add documentation
7d308cb
Merge branch 'master' into dynamic-elements-implementation
bd41b85
tag -> this
45d3ab0
fix: css classes for dynamic elements
a6a8ffd
Merge remote-tracking branch 'upstream/master' into dynamic-elements-…
baseballyama 80e93bc
replace double quote to single quote
baseballyama 7b5247d
fix lint
baseballyama 185332e
clean up nodes
baseballyama 714433b
little clean up render_dom
baseballyama 89d2733
refactor tag.ts
baseballyama 14ca990
refactor nodes
baseballyama ed2eed5
refactor render_dom
baseballyama 5d1bc8b
refactor render_dom
baseballyama 84d9f83
refactor render_dom
baseballyama d65da8d
add tests
baseballyama 7ced0ce
refactor render_ssr
baseballyama 24a338a
refactor render_ssr
baseballyama ca63111
fix named slot bug
baseballyama 85eab20
rafactor parse step
baseballyama e3c0091
refactor render_ssr
baseballyama 195452e
refactor render_ssr
baseballyama 8c9e93b
refactor parse step
baseballyama a86ec67
throw error if <svelte:element> uses animation
baseballyama 89dd933
move DynamicElementWrapper folder
baseballyama f8cc52a
merge DynamicElement to Element
baseballyama e2a36a4
Reuse DOM elements if possible.
baseballyama 75621dc
revert useless changes
baseballyama 42e4656
refactor
baseballyama d223df6
stop to use dynamic_element_block
baseballyama cdd7180
refactor render_dom
baseballyama 9068c90
refactor render_dom
baseballyama 9cd3fc6
refactor render_dom
baseballyama c77b73c
improve transition behavior
baseballyama f51d0f5
refactor render_dom
baseballyama 5160b2b
support animation
baseballyama da22d63
revert useless changes
baseballyama 11d12ab
use getter
baseballyama 25a12a7
refactor
baseballyama 9d76a92
make it more correct of claim_element
baseballyama 9863c5e
refactor
baseballyama b34b0ca
stop to use anonymous function
baseballyama 49bef3a
improve performance of render_ssr
baseballyama 6788b47
use child_dynamic_element
baseballyama 28b2665
Revert "support animation"
baseballyama 3a96f18
fix compile error
baseballyama 2e22241
refactor
baseballyama 7c0337a
stop reuse children of <svelte:element>
baseballyama 7b6dbcd
revert add_transitions
baseballyama 8560d7c
revert unnecessary changes
baseballyama 2171c67
fix in transition when tag of <svelte:element> changed
baseballyama d146c29
call of action when <svelte:element> tag changed
baseballyama 7a832d6
stop to transform to normal element even if svelte:element's value of…
baseballyama fa1b22a
Merge branch 'master' into dynamic-elements-implementation
baseballyama b437985
refactor redundant if statement
baseballyama 5850155
prevent to create element if value of `this` attribute is null / unde…
baseballyama dc25e2e
Merge branch 'master' into dynamic-elements-implementation
baseballyama 02cc14f
workaround ts error
baseballyama 6c71959
Merge branch 'master' into dynamic-elements-implementation
a8d7905
refactor update block, support animations, support falsy values, adju…
024a748
does not always need to create a new anchor
tanhauhau ef8a3f9
validate tag variable in dev mode
tanhauhau 4965010
support template literals
baseballyama 31573fd
add test for validating tag definition
baseballyama c5c0dee
remove useless validation
baseballyama 2858cf5
add test for shorthand this
baseballyama 1e86df5
add more parser validation test
tanhauhau f4a8e79
improve testcases
tanhauhau 0ef1dfc
animate while switching dynamic element
tanhauhau 13c6c12
fix test
tanhauhau 8057a14
add tutorial section
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
21 changes: 21 additions & 0 deletions
21
test/runtime/samples/dynamic-element-template-literals/_config.js
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,21 @@ | ||
| export default { | ||
| props: { | ||
| size: 1 | ||
| }, | ||
| html: '<h1>This is h1 tag</h1>', | ||
|
|
||
| test({ assert, component, target }) { | ||
| const h1 = target.firstChild; | ||
| component.size = 2; | ||
|
|
||
| assert.htmlEqual( | ||
| target.innerHTML, | ||
| ` | ||
| <h2>This is h2 tag</h2> | ||
| ` | ||
| ); | ||
|
|
||
| const h2 = target.firstChild; | ||
| assert.notEqual(h1, h2); | ||
| } | ||
| }; |
5 changes: 5 additions & 0 deletions
5
test/runtime/samples/dynamic-element-template-literals/main.svelte
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,5 @@ | ||
| <script> | ||
| export let size; | ||
| </script> | ||
|
|
||
| <svelte:element this="{`h${size}`}">This is h{size} tag</svelte:element> |
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.
Uh oh!
There was an error while loading. Please reload this page.