Skip to content
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

fix(vdom): properly warn for step attr on input #3196

Merged
merged 1 commit into from
Dec 29, 2021
Merged
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
18 changes: 12 additions & 6 deletions src/runtime/vdom/h.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,22 @@ const convertToPrivate = (node: d.ChildNode): d.VNode => {
return vnode;
};

const validateInputProperties = (vnodeData: any) => {
const props = Object.keys(vnodeData);
const typeIndex = props.indexOf('type');
const minIndex = props.indexOf('min');
const maxIndex = props.indexOf('max');
const stepIndex = props.indexOf('min');
/**
* Validates the ordering of attributes on an input element
* @param inputElm the element to validate
*/
const validateInputProperties = (inputElm: HTMLInputElement): void => {
const props = Object.keys(inputElm);

const value = props.indexOf('value');
if (value === -1) {
return;
}

const typeIndex = props.indexOf('type');
const minIndex = props.indexOf('min');
const maxIndex = props.indexOf('max');
const stepIndex = props.indexOf('step');
if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
}
Expand Down