Skip to content

Fix: input type number warning in browsers #4772

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

Merged
merged 1 commit into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/runtime/internal/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export function get_binding_group_value(group) {
}

export function to_number(value) {
return value === '' ? undefined : +value;
return value === '' ? null : +value;
}

export function time_ranges_to_array(ranges) {
Expand Down
6 changes: 3 additions & 3 deletions test/runtime/samples/binding-input-number/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ export default {
<p>number 44</p>
`);

// empty string should be treated as undefined
// empty string should be treated as null
input.value = '';
await input.dispatchEvent(event);

assert.equal(component.count, undefined);
assert.equal(component.count, null);
assert.htmlEqual(target.innerHTML, `
<input type='number'>
<p>undefined undefined</p>
<p>object null</p>
`);
},
};