svelte-material-ui
svelte-material-ui copied to clipboard
<Textfield/> does not handle input$readOnly attribute correctly.
Describe the bug
<Textfield/>
does not handle input$readOnly
attribute correctly. Tested with SMUI version 7.0.0
To Reproduce Steps to reproduce the behavior:
- Use
<TextField ... input$readOnly="{true}"/>
- Use
<TextField ... input$readOnly="{false}"/>
Idea for this code comes from https://github.com/hperrin/svelte-material-ui/issues/280#issuecomment-917448818
Expected behavior
In first case there should be HTML code in style
<input ... readonly/>
In second case there should be attribute readonly
omitted but it is rendered as
<input type="text" readonly="false"/>
that is wrong as readonly="false"
is is interpreted by browser as readonly="true"
.
See https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attribute and https://html.spec.whatwg.org/multipage/input.html#attr-input-readonly for explanation.
Additional comments The problem is that following code does not work.
<script>
import Textfield from "@smui/textfield";
let ro : boolean = false;
</script>
<TextField ... input$readonly="{ro}"/>