Scoped CSS properties overridden when multiple instances of same component
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 46
- Avg merge
- 10m
- Merged PRs (30d)
- 2
Description
I'm using JavaScript to generate scoped CSS based on props passed to the component.
For example, inside of _components/flex-box.webc:
<script webc:type="js" webc:is="style" webc:scoped>
`
:host {
display: flex;
flex-direction: ${direction};
}
`
</script>
The problem is when multiple instances of the same component are on the same page.
Sharing the same CSS class, only the last styles apply.
For example, inside of index.webc:
<flex-box @direction="row"></flex-box>
<flex-box @direction="column"></flex-box>
flex-direction: column; would override flex-direction: row;, assigning the same property to both elements.
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 with _components/flex-box.webc and index.webc, then inspect how webc:is="style" with webc:scoped is processed when the same component appears more than once. Reproduce the two directions shown in the issue and compare the generated styles. Done means each flex-box instance retains its own prop-specific flex-direction.
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