Skip to content

Commit 7ffc02e

Browse files
authored
fix(vdom): properly warn for step attr on input (#3196)
fix `indexOf` call for the step attribute to look for the correct attribute name. hoist the check for `value` attribute to exit early if the attribute does not exist, avoiding unneeded lookups of other attributes STENCIL-79: Fix typo on <input> attribute validations
1 parent 4a5da0f commit 7ffc02e

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

  • src/runtime/vdom

src/runtime/vdom/h.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,22 @@ const convertToPrivate = (node: d.ChildNode): d.VNode => {
163163
return vnode;
164164
};
165165

166-
const validateInputProperties = (vnodeData: any) => {
167-
const props = Object.keys(vnodeData);
168-
const typeIndex = props.indexOf('type');
169-
const minIndex = props.indexOf('min');
170-
const maxIndex = props.indexOf('max');
171-
const stepIndex = props.indexOf('min');
166+
/**
167+
* Validates the ordering of attributes on an input element
168+
* @param inputElm the element to validate
169+
*/
170+
const validateInputProperties = (inputElm: HTMLInputElement): void => {
171+
const props = Object.keys(inputElm);
172+
172173
const value = props.indexOf('value');
173174
if (value === -1) {
174175
return;
175176
}
177+
178+
const typeIndex = props.indexOf('type');
179+
const minIndex = props.indexOf('min');
180+
const maxIndex = props.indexOf('max');
181+
const stepIndex = props.indexOf('step');
176182
if (value < typeIndex || value < minIndex || value < maxIndex || value < stepIndex) {
177183
consoleDevWarn(`The "value" prop of <input> should be set after "min", "max", "type" and "step"`);
178184
}

0 commit comments

Comments
 (0)