Skip to content

Commit

Permalink
fix of the type mis-matched problem
Browse files Browse the repository at this point in the history
  • Loading branch information
xieguigang committed Feb 26, 2024
1 parent 9592ee5 commit 1cd814a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion LINQ.ts/DOM/InputValueSetter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@
* 如果目标id标记的控件不是输入类型的,则如果处于非严格模式下,
* 即这个参数为``false``的时候会直接强制读取value属性值
*/
export function setValue(resource: string, value: string, strict: boolean = true) {
export function setValue(resource: string, value: string | number | boolean, strict: boolean = true) {
let input = $ts(resource);
let type: TypeScript.Reflection.TypeInfo = $ts.typeof(input);

if (isNullOrUndefined(value)) {
value = "0";
}

if (!(typeof value === "string")) {
value = value.toString();
}

if (type.isEnumerator) {
setValues(new DOMEnumerator<IHTMLElement>(<any>input), value, strict);
} else {
Expand Down
2 changes: 1 addition & 1 deletion LINQ.ts/Framework/Define/Abstracts/TS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
*
* @returns 对于checkbox类型的input而言,逻辑值是以字符串的形式返回
*/
value(id: string, set_value?: string, strict?: boolean): any;
value(id: string, set_value?: string | number | boolean, strict?: boolean): any;

typeof<T extends object>(any: T): TypeScript.Reflection.TypeInfo;
clone<T>(obj: T): T;
Expand Down
2 changes: 1 addition & 1 deletion LINQ.ts/Framework/Define/Internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ namespace Internal {
}
HttpHelpers.Imports.doEval(script, callback);
}
ts.value = function (resource: string, value: string = null, strict: boolean = false) {
ts.value = function (resource: string, value: string | number | boolean = null, strict: boolean = false) {
if (isNullOrUndefined(value)) {
return DOM.InputValueGetter.getValue(resource, strict);
} else {
Expand Down

0 comments on commit 1cd814a

Please sign in to comment.