Skip to content

Commit

Permalink
fix(dev): add <input> value order warning
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Nov 15, 2019
1 parent b5353bd commit 4124720
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/runtime/vdom/h.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import * as d from '../../declarations';
import { BUILD } from '@build-conditionals';
import { consoleDevError } from '@platform';
import { consoleDevError, consoleDevWarn } from '@platform';
import { isComplexType } from '@utils';

// const stack: any[] = [];
Expand Down Expand Up @@ -52,6 +52,9 @@ Empty objects can also be the cause, look for JSX comments that became objects.`
};
walk(children);
if (vnodeData) {
if (BUILD.isDev && nodeName === 'input') {
validateInputProperties(vnodeData);
}
// normalize class / classname attributes
if (BUILD.vdomKey && vnodeData.key) {
key = vnodeData.key;
Expand Down Expand Up @@ -144,3 +147,15 @@ const convertToPrivate = (node: d.ChildNode): d.VNode => {
vnode.$name$ = node.vname;
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');

This comment has been minimized.

Copy link
@d0whc3r

d0whc3r Nov 18, 2019

should it be "step" instead of "min"?

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

0 comments on commit 4124720

Please sign in to comment.