I am creating a radio web component with Stencil.js.
Stencil.js code:
<div>
<slot/>
<label>
{this.label} <span/>
</label>
</div>
I pass an input of type radio. Usage in Angular:
<my-radio label="{{fruit}}">
<input name="fruits" type="radio" id="{{fruit}}">
</my-radio>
When I click it the "input" I expect it should change from <input name="fruits" type="radio" id="banana">
to <input name="fruits" type="radio" id="banana" checked>
.
But the input never gets the attribut "checked" even though everything is rendered properly. What am I doing wrong?
That's expected behavior that is independent of Stencil.
MDN's docs on the radio checked attribute:
The MDN docs for checkboxes make it more clear:
You can use the
checked
property instead to get the current value: