-
-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
svelte: enable two-way binding for ListInput component #213
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -193,7 +193,7 @@ | |||||||||||
{:else} | ||||||||||||
<!-- svelte-ignore a11y-autofocus --> | ||||||||||||
{#if type === 'select'} | ||||||||||||
<svelte:element | ||||||||||||
<select | ||||||||||||
this={InputComponent} | ||||||||||||
id={inputId} | ||||||||||||
bind:this={inputEl} | ||||||||||||
|
@@ -217,28 +217,63 @@ | |||||||||||
{min} | ||||||||||||
{minlength} | ||||||||||||
{step} | ||||||||||||
{multiple} | ||||||||||||
{...{ multiple }} | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean the value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the component will update when the parent changes the value. This line just bypasses Svelte's static check. |
||||||||||||
{readonly} | ||||||||||||
{required} | ||||||||||||
{pattern} | ||||||||||||
{tabindex} | ||||||||||||
{value} | ||||||||||||
bind:value | ||||||||||||
on:input={onInput} | ||||||||||||
on:change={onChange} | ||||||||||||
on:focus={onFocusInternal} | ||||||||||||
on:blur={onBlurInternal} | ||||||||||||
> | ||||||||||||
<slot /> | ||||||||||||
</svelte:element> | ||||||||||||
</select> | ||||||||||||
{:else if type !== 'textarea'} | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit, but I'd do:
Suggested change
|
||||||||||||
<input | ||||||||||||
this={InputComponent} | ||||||||||||
id={inputId} | ||||||||||||
bind:this={inputEl} | ||||||||||||
class={c.input[labelStyleIsFloating]} | ||||||||||||
style={inputStyle} | ||||||||||||
{name} | ||||||||||||
{...{ type }} | ||||||||||||
{placeholder} | ||||||||||||
{inputmode} | ||||||||||||
{size} | ||||||||||||
{accept} | ||||||||||||
{autocomplete} | ||||||||||||
{autocorrect} | ||||||||||||
{autocapitalize} | ||||||||||||
{spellcheck} | ||||||||||||
{autofocus} | ||||||||||||
{autosave} | ||||||||||||
{disabled} | ||||||||||||
{max} | ||||||||||||
{maxlength} | ||||||||||||
{min} | ||||||||||||
{minlength} | ||||||||||||
{step} | ||||||||||||
{multiple} | ||||||||||||
{readonly} | ||||||||||||
{required} | ||||||||||||
{pattern} | ||||||||||||
{tabindex} | ||||||||||||
bind:value | ||||||||||||
on:input={onInput} | ||||||||||||
on:change={onChange} | ||||||||||||
on:focus={onFocusInternal} | ||||||||||||
on:blur={onBlurInternal} | ||||||||||||
/> | ||||||||||||
{:else} | ||||||||||||
<svelte:element | ||||||||||||
<textarea | ||||||||||||
this={InputComponent} | ||||||||||||
id={inputId} | ||||||||||||
bind:this={inputEl} | ||||||||||||
class={c.input[labelStyleIsFloating]} | ||||||||||||
style={inputStyle} | ||||||||||||
{name} | ||||||||||||
type={needsType ? type : undefined} | ||||||||||||
{placeholder} | ||||||||||||
{inputmode} | ||||||||||||
{size} | ||||||||||||
|
@@ -260,7 +295,7 @@ | |||||||||||
{required} | ||||||||||||
{pattern} | ||||||||||||
{tabindex} | ||||||||||||
{value} | ||||||||||||
bind:value | ||||||||||||
on:input={onInput} | ||||||||||||
on:change={onChange} | ||||||||||||
on:focus={onFocusInternal} | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and in the other cases, is this still needed? I thought this is what determined what tag was used when using
svelte:element
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. It's not necessary, but I left it there to minimize code changes. I'll remove it (along with some other unnecessary lines), as I've already made more changes than I initially expected.