@visactor/vrender-core
Version:
```typescript import { xxx } from '@visactor/vrender-core'; ```
11 lines (10 loc) • 431 B
JavaScript
import { isEqual } from "@visactor/vutils";
export function diff(oldAttrs, newAttrs, getAttr) {
const diffObj = {};
for (const key in newAttrs) key in oldAttrs && isEqual(oldAttrs[key], newAttrs[key]) || (diffObj[key] = newAttrs[key]);
if (getAttr) for (const key in oldAttrs) if (!(key in newAttrs)) {
const value = getAttr(key);
void 0 !== value && (diffObj[key] = value);
}
return diffObj;
}