Skip to content

Commit 32537e1

Browse files
committedJun 29, 2023
fix: less strict obj checks for undefined and missing keys closes #4341
1 parent ffa7318 commit 32537e1

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed
 

‎.changeset/eighty-zebras-listen.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'vee-validate': patch
3+
---
4+
5+
fix: less strict object checks for undefined and missing keys closes #4341

‎packages/vee-validate/src/utils/assertions.ts

-3
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ export function isEqual(a: any, b: any) {
163163

164164
keys = Object.keys(a);
165165
length = keys.length;
166-
if (length !== Object.keys(b).length) return false;
167-
168-
for (i = length; i-- !== 0; ) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
169166

170167
for (i = length; i-- !== 0; ) {
171168
// eslint-disable-next-line no-var

‎packages/vee-validate/tests/useForm.spec.ts

+23
Original file line numberDiff line numberDiff line change
@@ -1134,4 +1134,27 @@ describe('useForm()', () => {
11341134
expect(document.body.innerHTML).toContain('aria-valid="true"');
11351135
});
11361136
});
1137+
1138+
// #4341
1139+
test('undefined field value should be the same as missing value when it comes to dirty', async () => {
1140+
let form!: FormContext<any>;
1141+
mountWithHoc({
1142+
setup() {
1143+
form = useForm({
1144+
initialValues: {
1145+
fname: '',
1146+
},
1147+
});
1148+
1149+
useField('fname');
1150+
useField('lname');
1151+
1152+
return {};
1153+
},
1154+
template: `<div></div>`,
1155+
});
1156+
1157+
await flushPromises();
1158+
expect(form.meta.value.dirty).toBe(false);
1159+
});
11371160
});

0 commit comments

Comments
 (0)
Please sign in to comment.