Match-id-78d18a3a10c1983fdde7d98301473163a17c6005
This commit is contained in:
parent
44bdfa50d0
commit
3e0777eee4
|
@ -71,8 +71,7 @@ export function compareProps(
|
||||||
newProps: Object,
|
newProps: Object,
|
||||||
): Array<any> {
|
): Array<any> {
|
||||||
let updatesForStyle = {};
|
let updatesForStyle = {};
|
||||||
const toBeDeletedProps: Array<any> = [];
|
const toUpdateProps: Array<any> = [];
|
||||||
const toBeUpdatedProps: Array<any> = [];
|
|
||||||
const keysOfOldProps = Object.keys(oldProps);
|
const keysOfOldProps = Object.keys(oldProps);
|
||||||
const keysOfNewProps = Object.keys(newProps);
|
const keysOfNewProps = Object.keys(newProps);
|
||||||
|
|
||||||
|
@ -104,14 +103,14 @@ export function compareProps(
|
||||||
continue;
|
continue;
|
||||||
} else if (isEventProp(propName)) {
|
} else if (isEventProp(propName)) {
|
||||||
if (!allDelegatedHorizonEvents.has(propName)) {
|
if (!allDelegatedHorizonEvents.has(propName)) {
|
||||||
toBeDeletedProps.push({
|
toUpdateProps.push({
|
||||||
propName,
|
propName,
|
||||||
propVal: null,
|
propVal: null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 其它属性都要加入到删除队列里面,等待删除
|
// 其它属性都要加入到删除队列里面,等待删除
|
||||||
toBeDeletedProps.push({
|
toUpdateProps.push({
|
||||||
propName,
|
propName,
|
||||||
propVal: null,
|
propVal: null,
|
||||||
});
|
});
|
||||||
|
@ -156,7 +155,7 @@ export function compareProps(
|
||||||
}
|
}
|
||||||
} else { // 之前未设置 style 属性或者设置了空值
|
} else { // 之前未设置 style 属性或者设置了空值
|
||||||
if (Object.keys(updatesForStyle).length === 0) {
|
if (Object.keys(updatesForStyle).length === 0) {
|
||||||
toBeUpdatedProps.push({
|
toUpdateProps.push({
|
||||||
propName,
|
propName,
|
||||||
propVal: null,
|
propVal: null,
|
||||||
});
|
});
|
||||||
|
@ -168,7 +167,7 @@ export function compareProps(
|
||||||
oldHTML = oldPropValue ? oldPropValue.__html : undefined;
|
oldHTML = oldPropValue ? oldPropValue.__html : undefined;
|
||||||
if (newHTML != null) {
|
if (newHTML != null) {
|
||||||
if (oldHTML !== newHTML) {
|
if (oldHTML !== newHTML) {
|
||||||
toBeUpdatedProps.push({
|
toUpdateProps.push({
|
||||||
propName,
|
propName,
|
||||||
propVal: newPropValue,
|
propVal: newPropValue,
|
||||||
});
|
});
|
||||||
|
@ -176,20 +175,20 @@ export function compareProps(
|
||||||
}
|
}
|
||||||
} else if (propName === 'children') {
|
} else if (propName === 'children') {
|
||||||
if (typeof newPropValue === 'string' || typeof newPropValue === 'number') {
|
if (typeof newPropValue === 'string' || typeof newPropValue === 'number') {
|
||||||
toBeUpdatedProps.push({
|
toUpdateProps.push({
|
||||||
propName,
|
propName,
|
||||||
propVal: String(newPropValue),
|
propVal: String(newPropValue),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (isEventProp(propName)) {
|
} else if (isEventProp(propName)) {
|
||||||
if (!allDelegatedHorizonEvents.has(propName)) {
|
if (!allDelegatedHorizonEvents.has(propName)) {
|
||||||
toBeUpdatedProps.push({
|
toUpdateProps.push({
|
||||||
propName,
|
propName,
|
||||||
propVal: newPropValue,
|
propVal: newPropValue,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toBeUpdatedProps.push({
|
toUpdateProps.push({
|
||||||
propName,
|
propName,
|
||||||
propVal: newPropValue,
|
propVal: newPropValue,
|
||||||
});
|
});
|
||||||
|
@ -198,11 +197,11 @@ export function compareProps(
|
||||||
|
|
||||||
// 处理style
|
// 处理style
|
||||||
if (Object.keys(updatesForStyle).length > 0) {
|
if (Object.keys(updatesForStyle).length > 0) {
|
||||||
toBeUpdatedProps.push({
|
toUpdateProps.push({
|
||||||
propName: 'style',
|
propName: 'style',
|
||||||
propVal: updatesForStyle,
|
propVal: updatesForStyle,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return [...toBeDeletedProps, ...toBeUpdatedProps];
|
return toUpdateProps;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue