Match-id-7839b5cc6a49de4445d87b458c40a79570ade7ba
This commit is contained in:
parent
1ed7e608cc
commit
4d173bd7a0
|
@ -8,28 +8,6 @@ import {
|
||||||
} from '../../event/EventBinding';
|
} from '../../event/EventBinding';
|
||||||
import { isEventProp, isNativeElement } from '../validators/ValidateProps';
|
import { isEventProp, isNativeElement } from '../validators/ValidateProps';
|
||||||
|
|
||||||
function updateOneProp(dom, propName, isNativeTag, propVal?, isInit?: boolean) {
|
|
||||||
if (propName === 'style') {
|
|
||||||
setStyles(dom, propVal);
|
|
||||||
} else if (isEventProp(propName)) {
|
|
||||||
// 事件监听属性处理
|
|
||||||
if (!allDelegatedHorizonEvents.has(propName)) {
|
|
||||||
listenNonDelegatedEvent(propName, dom, propVal);
|
|
||||||
}
|
|
||||||
} else if (propName === 'children') { // 只处理纯文本子节点,其他children在VNode树中处理
|
|
||||||
const type = typeof propVal;
|
|
||||||
if (type === 'string' || type === 'number') {
|
|
||||||
dom.textContent = propVal;
|
|
||||||
}
|
|
||||||
} else if (propName === 'dangerouslySetInnerHTML') {
|
|
||||||
dom.innerHTML = propVal.__html;
|
|
||||||
} else {
|
|
||||||
if (!isInit || (isInit && propVal != null)) {
|
|
||||||
updateCommonProp(dom, propName, propVal, isNativeTag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 初始化DOM属性
|
// 初始化DOM属性
|
||||||
export function setDomProps(
|
export function setDomProps(
|
||||||
tagName: string,
|
tagName: string,
|
||||||
|
@ -45,7 +23,25 @@ export function setDomProps(
|
||||||
propName = keysOfProps[i];
|
propName = keysOfProps[i];
|
||||||
propVal = props[propName];
|
propVal = props[propName];
|
||||||
|
|
||||||
updateOneProp(dom, propName, isNativeTag, propVal, true);
|
if (propName === 'style') {
|
||||||
|
setStyles(dom, propVal);
|
||||||
|
} else if (isEventProp(propName)) {
|
||||||
|
// 事件监听属性处理
|
||||||
|
if (!allDelegatedHorizonEvents.has(propName)) {
|
||||||
|
listenNonDelegatedEvent(propName, dom, propVal);
|
||||||
|
}
|
||||||
|
} else if (propName === 'children') { // 只处理纯文本子节点,其他children在VNode树中处理
|
||||||
|
const type = typeof propVal;
|
||||||
|
if (type === 'string' || type === 'number') {
|
||||||
|
dom.textContent = propVal;
|
||||||
|
}
|
||||||
|
} else if (propName === 'dangerouslySetInnerHTML') {
|
||||||
|
dom.innerHTML = propVal.__html;
|
||||||
|
} else {
|
||||||
|
if (propVal != null) {
|
||||||
|
updateCommonProp(dom, propName, propVal, isNativeTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +52,23 @@ export function updateDomProps(
|
||||||
isNativeTag: boolean,
|
isNativeTag: boolean,
|
||||||
): void {
|
): void {
|
||||||
for(const [propName, propVal] of changeList) {
|
for(const [propName, propVal] of changeList) {
|
||||||
updateOneProp(dom, propName, isNativeTag, propVal);
|
if (propName === 'style') {
|
||||||
|
setStyles(dom, propVal);
|
||||||
|
} else if (isEventProp(propName)) {
|
||||||
|
// 事件监听属性处理
|
||||||
|
if (!allDelegatedHorizonEvents.has(propName)) {
|
||||||
|
listenNonDelegatedEvent(propName, dom, propVal);
|
||||||
|
}
|
||||||
|
} else if (propName === 'children') { // 只处理纯文本子节点,其他children在VNode树中处理
|
||||||
|
const type = typeof propVal;
|
||||||
|
if (type === 'string' || type === 'number') {
|
||||||
|
dom.textContent = propVal;
|
||||||
|
}
|
||||||
|
} else if (propName === 'dangerouslySetInnerHTML') {
|
||||||
|
dom.innerHTML = propVal.__html;
|
||||||
|
} else {
|
||||||
|
updateCommonProp(dom, propName, propVal, isNativeTag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue