Skip to content

Commit

Permalink
fix: use deep-fast-equal module for changed flag closes #3320
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed May 26, 2021
1 parent 1d0c054 commit fd5bacb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 36 deletions.
3 changes: 2 additions & 1 deletion src/components/Provider.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable @typescript-eslint/ban-types */
import Vue, { CreateElement, VNode, VueConstructor } from 'vue';
import isEqual from 'fast-deep-equal/es6';

This comment has been minimized.

Copy link
@rs3d

rs3d May 27, 2021

Unfortunately this seems to break IE11 support. @logaretm
Could you use the es5 version here?

This comment has been minimized.

Copy link
@logaretm

logaretm May 28, 2021

Author Owner

Yea sure!

import { normalizeRules, extractLocators } from '../utils/rules';
import { normalizeEventValue } from '../utils/events';
import { findInputNodes, normalizeChildren, resolveRules, isHTMLNode } from '../utils/vnode';
import { isCallable, isEqual, isNullOrUndefined, createFlags, includes, isLocator } from '../utils';
import { isCallable, isNullOrUndefined, createFlags, includes, isLocator } from '../utils';
import { getConfig, ValidationClassMap } from '../config';
import { validate } from '../validate';
import { RuleContainer } from '../extend';
Expand Down
36 changes: 1 addition & 35 deletions src/utils/assertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,41 +28,6 @@ export function isRefEqual(lhs: any, rhs: any) {
return lhs === rhs;
}

/**
* Shallow object comparison.
*/
export function isEqual(lhs: any, rhs: any): boolean {
if (lhs instanceof RegExp && rhs instanceof RegExp) {
return isEqual(lhs.source, rhs.source) && isEqual(lhs.flags, rhs.flags);
}

if (Array.isArray(lhs) && Array.isArray(rhs)) {
if (lhs.length !== rhs.length) return false;

for (let i = 0; i < lhs.length; i++) {
if (!isEqual(lhs[i], rhs[i])) {
return false;
}
}

return true;
}

// if both are objects, compare each key recursively.
if (isObject(lhs) && isObject(rhs)) {
return (
Object.keys(lhs).every(key => {
return isEqual(lhs[key], rhs[key]);
}) &&
Object.keys(rhs).every(key => {
return isEqual(lhs[key], rhs[key]);
})
);
}

return isRefEqual(lhs, rhs);
}

// Checks if a given value is not an empty string or null or undefined.
export function isSpecified(val: string | null | undefined): boolean {
if (val === '') {
Expand All @@ -72,6 +37,7 @@ export function isSpecified(val: string | null | undefined): boolean {
return !isNullOrUndefined(val);
}

// eslint-disable-next-line @typescript-eslint/ban-types
export function isCallable(fn: unknown): fn is Function {
return typeof fn === 'function';
}
Expand Down

0 comments on commit fd5bacb

Please sign in to comment.