-
-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
I was trying to create a reusable <select> component, and my naive approach was to use slots, but that didn't work. I've resorted to using a render function within my custom select WebC component and it works now. However, to be generic, I'm trying to pass data in as an object and dynamically render it on the other side. The reproduction and the workaround I've found are at the bottom of this issue.
Bug
<!-- Main component -->
<script webc:setup>
function options() {
return [
"1",
"2",
"3",
"4",
];
}
</script>
<cr-fieldset>
<cr-select
name="motivation"
:@options="options()"
></cr-select>
</cr-fieldset><!-- cr-fieldset -->
<fieldset :data-required="required">
<legend>
<h2 @text="title"></h2>
<p @text="label"></p>
</legend>
<slot></slot>
</fieldset><!-- cr-select -->
<select
:name="name"
>
<option value="">Please select</option>
<script webc:type="js" webc:root>
options
.map((value) => `<option value="${value}">${value}</option>`)
.join("\n");
</script>
</select>This results in the follow error:
Reproduction
Reproduction commit: darthmall/webc-select-options-setup-func-repro@247df02
I managed to get around the issue by pulling the setup script and <cr-select> to a separate file.
Workaround commit: darthmall/webc-select-options-setup-func-repro@df8ef9b
Metadata
Metadata
Assignees
Labels
No labels