skatejs-dom-diff
Version:
Library for efficiently diffing and patching DOM fragments.
36 lines (31 loc) • 776 B
JavaScript
import { SET_PROPERTY } from '../types';
export default function (src, tar) {
const { properties: srcValues } = src;
const { properties: tarValues } = tar;
const instructions = [];
for (let name in srcValues) {
const srcValue = srcValues[name];
const tarValue = tarValues[name];
if (srcValue !== tarValue) {
instructions.push({
data: { name },
target: tar,
source: src,
type: SET_PROPERTY
});
}
}
for (let name in tarValues) {
const srcValue = srcValues[name];
const tarValue = tarValues[name];
if (srcValue !== tarValue) {
instructions.push({
data: { name },
target: tar,
source: src,
type: SET_PROPERTY
});
}
}
return instructions;
}