Match-id-20f906ffbbc23478561e56623690bbcb516e0f46

This commit is contained in:
* 2022-01-13 18:03:27 +08:00 committed by *
commit bd50434e32
3 changed files with 14 additions and 13 deletions

View File

@ -1,12 +1,12 @@
import { import {
allDelegatedHorizonEvents, allDelegatedHorizonEvents,
} from '../../event/EventCollection'; } from '../../event/EventCollection';
import {updateCommonProp} from './UpdateCommonProp'; import { updateCommonProp } from './UpdateCommonProp';
import {setStyles} from './StyleHandler'; import { setStyles } from './StyleHandler';
import { import {
listenNonDelegatedEvent listenNonDelegatedEvent
} from '../../event/EventBinding'; } from '../../event/EventBinding';
import {isEventProp, isNativeElement} from '../validators/ValidateProps'; import { isEventProp, isNativeElement } from '../validators/ValidateProps';
// 初始化DOM属性 // 初始化DOM属性
export function setDomProps( export function setDomProps(
@ -31,14 +31,14 @@ export function updateDomProps(
changeList: Array<any>, changeList: Array<any>,
isNativeTag: boolean, isNativeTag: boolean,
): void { ): void {
for (let i = 0; i < changeList.length; i ++) { for (let i = 0; i < changeList.length; i++) {
const {propName, propVal} = changeList[i]; const { propName, propVal } = changeList[i];
updateOneProp(dom, propName, propVal, isNativeTag); updateOneProp(dom, propName, propVal, isNativeTag);
} }
} }
function updateOneProp(dom, propName, propVal, isNativeTag, isInit = false) { function updateOneProp(dom, propName, propVal, isNativeTag, isInit?: boolean) {
if (propName === 'style') { if (propName === 'style') {
setStyles(dom, propVal); setStyles(dom, propVal);
} else if (propName === 'dangerouslySetInnerHTML') { } else if (propName === 'dangerouslySetInnerHTML') {
@ -65,8 +65,8 @@ export function compareProps(
newProps: Object, newProps: Object,
): Array<any> { ): Array<any> {
let updatesForStyle = {}; let updatesForStyle = {};
const toBeDeletedProps = []; const toBeDeletedProps: Array<any> = [];
const toBeUpdatedProps = []; const toBeUpdatedProps: Array<any> = [];
const keysOfOldProps = Object.keys(oldProps); const keysOfOldProps = Object.keys(oldProps);
const keysOfNewProps = Object.keys(newProps); const keysOfNewProps = Object.keys(newProps);
@ -124,7 +124,7 @@ export function compareProps(
const oldStyleProps = Object.keys(oldPropValue); const oldStyleProps = Object.keys(oldPropValue);
for (let j = 0; j < oldStyleProps.length; j++) { for (let j = 0; j < oldStyleProps.length; j++) {
const styleProp = oldStyleProps[j]; const styleProp = oldStyleProps[j];
if (!newPropValue || !newPropValue.hasOwnProperty(styleProp)) { if (!newPropValue || !Object.prototype.hasOwnProperty.call(newPropValue, styleProp)) {
updatesForStyle[styleProp] = ''; updatesForStyle[styleProp] = '';
} }
} }

View File

@ -7,7 +7,7 @@ const HANDLER_KEY = '_valueChangeHandler';
// 判断是否是 check 类型 // 判断是否是 check 类型
function isCheckType(dom: HTMLInputElement): boolean { function isCheckType(dom: HTMLInputElement): boolean {
const {type, nodeName} = dom; const { type, nodeName } = dom;
if (nodeName && nodeName.toLowerCase() === 'input') { if (nodeName && nodeName.toLowerCase() === 'input') {
return type === 'checkbox' || type === 'radio'; return type === 'checkbox' || type === 'radio';
} }
@ -27,7 +27,7 @@ export function watchValueChange(dom) {
// 获取 value 属性的描述信息,其 value 在其 constructor 的 原型上 // 获取 value 属性的描述信息,其 value 在其 constructor 的 原型上
const descriptor = Object.getOwnPropertyDescriptor(dom.constructor.prototype, keyForValue); const descriptor = Object.getOwnPropertyDescriptor(dom.constructor.prototype, keyForValue);
if (dom.hasOwnProperty(keyForValue)) { if (Object.prototype.hasOwnProperty.call(dom, keyForValue)) {
return; return;
} }
@ -37,7 +37,7 @@ export function watchValueChange(dom) {
const setFunc = descriptor.set; const setFunc = descriptor.set;
Object.defineProperty(dom, keyForValue, { Object.defineProperty(dom, keyForValue, {
...descriptor, ...descriptor,
set: function(value) { set: function (value) {
currentVal = String(value); currentVal = String(value);
setFunc.apply(this, [value]); setFunc.apply(this, [value]);
}, },

View File

@ -29,7 +29,8 @@
"types": [], // 使@types/node "types": [], // 使@types/node
"lib": ["dom", "esnext", "ES2015", "ES2016", "ES2017", "ES2018", "ES2019", "ES2020"], "lib": ["dom", "esnext", "ES2015", "ES2016", "ES2017", "ES2018", "ES2019", "ES2020"],
"baseUrl": ".", "baseUrl": ".",
"rootDir": "./libs" "rootDir": "./libs",
"strictNullChecks": true
}, },
"include": [ "include": [
"./libs/**/src/**/*.ts", "./libs/**/src/**/*.ts",