Support dynamic :webc:is value
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 46
- Avg merge
- 10m
- Merged PRs (30d)
- 2
Description
Hey! Doesn't seem like an urgent fix but...
This does not work properly (or at least not as I expected):
<div :webc:is="'my-component'" @test="Dynamic comp name does not pass props"></div>
The component renders but the test prop is not passed.
The workaround is probably to use a script.
<script webc:type="js">
`<${"my-component"} @test="Template string comp name works"></${"my-component"}>`
+ // OR
`<div webc:is="${"my-component"}" @test="Template string comp name works"></div>`;
</script>
Both work as expected.
My use case was the following:
I wanted to loop over an array of data with each entry containing the name of the component to be used and the props to be passed to said component.
I was trying something like this:
<div
webc:for="block of blocks"
:webc:is="block.tag"
@attributes="block"
></div>
It looks super neat and compact! (but it does not work 😭😄)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the :webc:is examples in the issue, including the webc:for loop, and inspect the implementation that resolves dynamic component names. Done means a component selected from a dynamic value receives its @test or @attributes props, matching the script workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100