Match-id-6f710b5df19f2be04f61b75b3de8f6776ec4d2d1
This commit is contained in:
parent
2cddb7a6e5
commit
e69a465590
|
@ -22,32 +22,32 @@ import {
|
||||||
} from './TextareaValueHandler';
|
} from './TextareaValueHandler';
|
||||||
|
|
||||||
// 获取元素除了被代理的值以外的属性
|
// 获取元素除了被代理的值以外的属性
|
||||||
function getPropsWithoutValue(type: string, dom: HorizonDom, properties: Props) {
|
function getPropsWithoutValue(type: string, dom: HorizonDom, props: Props) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'input':
|
case 'input':
|
||||||
return getInputPropsWithoutValue(<HTMLInputElement>dom, properties);
|
return getInputPropsWithoutValue(<HTMLInputElement>dom, props);
|
||||||
case 'option':
|
case 'option':
|
||||||
return getOptionPropsWithoutValue(dom, properties);
|
return getOptionPropsWithoutValue(dom, props);
|
||||||
case 'select':
|
case 'select':
|
||||||
return getSelectPropsWithoutValue(<HorizonSelect>dom, properties);
|
return getSelectPropsWithoutValue(<HorizonSelect>dom, props);
|
||||||
case 'textarea':
|
case 'textarea':
|
||||||
return getTextareaPropsWithoutValue(<HTMLTextAreaElement>dom, properties);
|
return getTextareaPropsWithoutValue(<HTMLTextAreaElement>dom, props);
|
||||||
default:
|
default:
|
||||||
return properties;
|
return props;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 其它属性挂载完成后处理被代理值相关的属性
|
// 其它属性挂载完成后处理被代理值相关的属性
|
||||||
function setInitValue(type: string, dom: HorizonDom, properties: Props) {
|
function setInitValue(type: string, dom: HorizonDom, props: Props) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'input':
|
case 'input':
|
||||||
setInitInputValue(<HTMLInputElement>dom, properties);
|
setInitInputValue(<HTMLInputElement>dom, props);
|
||||||
break;
|
break;
|
||||||
case 'select':
|
case 'select':
|
||||||
updateSelectValue(<HorizonSelect>dom, properties, true);
|
updateSelectValue(<HorizonSelect>dom, props, true);
|
||||||
break;
|
break;
|
||||||
case 'textarea':
|
case 'textarea':
|
||||||
updateTextareaValue(<HTMLTextAreaElement>dom, properties, true);
|
updateTextareaValue(<HTMLTextAreaElement>dom, props, true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -55,16 +55,16 @@ function setInitValue(type: string, dom: HorizonDom, properties: Props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新需要适配的属性
|
// 更新需要适配的属性
|
||||||
function updateValue(type: string, dom: HorizonDom, properties: Props) {
|
function updateValue(type: string, dom: HorizonDom, props: Props) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'input':
|
case 'input':
|
||||||
updateInputValue(<HTMLInputElement>dom, properties);
|
updateInputValue(<HTMLInputElement>dom, props);
|
||||||
break;
|
break;
|
||||||
case 'select':
|
case 'select':
|
||||||
updateSelectValue(<HorizonSelect>dom, properties);
|
updateSelectValue(<HorizonSelect>dom, props);
|
||||||
break;
|
break;
|
||||||
case 'textarea':
|
case 'textarea':
|
||||||
updateTextareaValue(<HTMLTextAreaElement>dom, properties);
|
updateTextareaValue(<HTMLTextAreaElement>dom, props);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -58,7 +58,7 @@ function controlValue(target: Element) {
|
||||||
function controlInputValue(inputDom: HTMLInputElement, props: Props) {
|
function controlInputValue(inputDom: HTMLInputElement, props: Props) {
|
||||||
const { name, type } = props;
|
const { name, type } = props;
|
||||||
|
|
||||||
// 如果是 radio,先更新相同 name 的 radio
|
// 如果是 radio,找出同一form内,name相同的Radio,更新它们Handler的Value
|
||||||
if (type === 'radio' && name != null) {
|
if (type === 'radio' && name != null) {
|
||||||
const radioList = document.querySelectorAll<HTMLInputElement>(`input[type="radio"][name="${name}"]`);
|
const radioList = document.querySelectorAll<HTMLInputElement>(`input[type="radio"][name="${name}"]`);
|
||||||
for (let i = 0; i < radioList.length; i++) {
|
for (let i = 0; i < radioList.length; i++) {
|
||||||
|
|
Loading…
Reference in New Issue