Can't seem to get `:attribute` working with `webc:root`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 46
- Avg merge
- 10m
- Merged PRs (30d)
- 2
Description
Here's a simple example of a component where I don't want a wrapping element:
<script webc:setup>
function featureSize(size) {
return `feature_${size.replace("/", "-")}`;
}
</script>
<section webc:root :class="featureSize(size)">
<!-- ... -->
</section>
This fails with:
[11ty] 1. Having trouble rendering webc template ./src/index.webc (via TemplateContentRenderError)
[11ty] 2. Evaluating a dynamic attribute failed: `:class="featureSize(size)"`.
[11ty] Original error message: featureSize is not a function (via Error)
I'm not sure how to best deal with this. Seems like js isn't accessible on the root element or something like that?
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 example in src/index.webc, focusing on the interaction between webc:setup, webc:root, and the dynamic :class attribute. Trace how the root element evaluates the attribute and determine the expected behavior; this is done when the example renders without the reported featureSize error and the intended class is applied.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100