Match-id-50587986d1edc80317f0cc466eca9a834a37dc62
This commit is contained in:
parent
3e0777eee4
commit
a59ffea5bc
|
@ -110,7 +110,7 @@ export function getPropChangeList(
|
||||||
type: string,
|
type: string,
|
||||||
lastRawProps: Props,
|
lastRawProps: Props,
|
||||||
nextRawProps: Props,
|
nextRawProps: Props,
|
||||||
): Array<any> {
|
): Map<string, any> {
|
||||||
// 校验两个对象的不同
|
// 校验两个对象的不同
|
||||||
validateProps(type, nextRawProps);
|
validateProps(type, nextRawProps);
|
||||||
|
|
||||||
|
|
|
@ -52,15 +52,10 @@ export function setDomProps(
|
||||||
// 更新 DOM 属性
|
// 更新 DOM 属性
|
||||||
export function updateDomProps(
|
export function updateDomProps(
|
||||||
dom: Element,
|
dom: Element,
|
||||||
changeList: Array<any>,
|
changeList: Map<string, any>,
|
||||||
isNativeTag: boolean,
|
isNativeTag: boolean,
|
||||||
): void {
|
): void {
|
||||||
const listLength = changeList.length;
|
for(const [propName, propVal] of changeList) {
|
||||||
let propName;
|
|
||||||
let propVal;
|
|
||||||
for (let i = 0; i < listLength; i++) {
|
|
||||||
propName = changeList[i].propName;
|
|
||||||
propVal = changeList[i].propVal;
|
|
||||||
updateOneProp(dom, propName, isNativeTag, propVal);
|
updateOneProp(dom, propName, isNativeTag, propVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,9 +64,9 @@ export function updateDomProps(
|
||||||
export function compareProps(
|
export function compareProps(
|
||||||
oldProps: Object,
|
oldProps: Object,
|
||||||
newProps: Object,
|
newProps: Object,
|
||||||
): Array<any> {
|
): Map<string, any> {
|
||||||
let updatesForStyle = {};
|
let updatesForStyle = {};
|
||||||
const toUpdateProps: Array<any> = [];
|
const toUpdateProps = new Map();
|
||||||
const keysOfOldProps = Object.keys(oldProps);
|
const keysOfOldProps = Object.keys(oldProps);
|
||||||
const keysOfNewProps = Object.keys(newProps);
|
const keysOfNewProps = Object.keys(newProps);
|
||||||
|
|
||||||
|
@ -103,17 +98,11 @@ export function compareProps(
|
||||||
continue;
|
continue;
|
||||||
} else if (isEventProp(propName)) {
|
} else if (isEventProp(propName)) {
|
||||||
if (!allDelegatedHorizonEvents.has(propName)) {
|
if (!allDelegatedHorizonEvents.has(propName)) {
|
||||||
toUpdateProps.push({
|
toUpdateProps.set(propName, null);
|
||||||
propName,
|
|
||||||
propVal: null,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 其它属性都要加入到删除队列里面,等待删除
|
// 其它属性都要加入到删除队列里面,等待删除
|
||||||
toUpdateProps.push({
|
toUpdateProps.set(propName, null);
|
||||||
propName,
|
|
||||||
propVal: null,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,10 +144,7 @@ export function compareProps(
|
||||||
}
|
}
|
||||||
} else { // 之前未设置 style 属性或者设置了空值
|
} else { // 之前未设置 style 属性或者设置了空值
|
||||||
if (Object.keys(updatesForStyle).length === 0) {
|
if (Object.keys(updatesForStyle).length === 0) {
|
||||||
toUpdateProps.push({
|
toUpdateProps.set(propName, null);
|
||||||
propName,
|
|
||||||
propVal: null,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
updatesForStyle = newPropValue;
|
updatesForStyle = newPropValue;
|
||||||
}
|
}
|
||||||
|
@ -167,40 +153,25 @@ 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) {
|
||||||
toUpdateProps.push({
|
toUpdateProps.set(propName, newPropValue);
|
||||||
propName,
|
|
||||||
propVal: newPropValue,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (propName === 'children') {
|
} else if (propName === 'children') {
|
||||||
if (typeof newPropValue === 'string' || typeof newPropValue === 'number') {
|
if (typeof newPropValue === 'string' || typeof newPropValue === 'number') {
|
||||||
toUpdateProps.push({
|
toUpdateProps.set(propName, String(newPropValue));
|
||||||
propName,
|
|
||||||
propVal: String(newPropValue),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else if (isEventProp(propName)) {
|
} else if (isEventProp(propName)) {
|
||||||
if (!allDelegatedHorizonEvents.has(propName)) {
|
if (!allDelegatedHorizonEvents.has(propName)) {
|
||||||
toUpdateProps.push({
|
toUpdateProps.set(propName, newPropValue);
|
||||||
propName,
|
|
||||||
propVal: newPropValue,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toUpdateProps.push({
|
toUpdateProps.set(propName, newPropValue);
|
||||||
propName,
|
|
||||||
propVal: newPropValue,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理style
|
// 处理style
|
||||||
if (Object.keys(updatesForStyle).length > 0) {
|
if (Object.keys(updatesForStyle).length > 0) {
|
||||||
toUpdateProps.push({
|
toUpdateProps.set('style', updatesForStyle);
|
||||||
propName: 'style',
|
|
||||||
propVal: updatesForStyle,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return toUpdateProps;
|
return toUpdateProps;
|
||||||
|
|
|
@ -44,7 +44,7 @@ function updateDom(
|
||||||
FlagUtils.markUpdate(processing);
|
FlagUtils.markUpdate(processing);
|
||||||
} else {
|
} else {
|
||||||
// 其它的类型,数据有变化才标记更新
|
// 其它的类型,数据有变化才标记更新
|
||||||
if (changeList.length) {
|
if (changeList.size) {
|
||||||
FlagUtils.markUpdate(processing);
|
FlagUtils.markUpdate(processing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue