Bladeren bron

nit: amend attributes filter on input html tag

wangweimin 3 jaren geleden
bovenliggende
commit
50623001f2
3 gewijzigde bestanden met toevoegingen van 12 en 27 verwijderingen
  1. 6 15
      webiojs/src/models/input/input.ts
  2. 4 11
      webiojs/src/models/input/select.ts
  3. 2 1
      webiojs/src/models/input/textarea.ts

+ 6 - 15
webiojs/src/models/input/input.ts

@@ -1,5 +1,5 @@
 import {InputItem} from "./base";
-import {deep_copy} from "../../utils"
+import {deep_copy, make_set} from "../../utils"
 import {state} from "../../state";
 
 const datalist_tpl = `
@@ -68,17 +68,8 @@ export class Input extends InputItem {
         }
 
         // 将额外的html参数加到input标签上
-        const ignore_keys = {
-            'action': '',
-            'type': '',
-            'label': '',
-            'invalid_feedback': '',
-            'valid_feedback': '',
-            'help_text': '',
-            'options': '',
-            'datalist': '',
-            'multiple': ''
-        };
+        const ignore_keys = make_set(['action', 'type', 'label', 'invalid_feedback', 'valid_feedback', 'help_text',
+            'options', 'datalist', 'multiple', 'onchange', 'onblur']);
         for (let key in this.spec) {
             if (key in ignore_keys) continue;
             input_elem.attr(key, this.spec[key]);
@@ -99,10 +90,10 @@ export class Input extends InputItem {
     }
 
     get_value(): any {
-        let val= this.element.find('input').val();
-        if(this.spec['type']=='number')
+        let val = this.element.find('input').val();
+        if (this.spec['type'] == 'number')
             val = parseInt(val as string);
-        else if (this.spec['type']=='float')
+        else if (this.spec['type'] == 'float')
             val = parseFloat(val as string);
         return val;
     }

+ 4 - 11
webiojs/src/models/input/select.ts

@@ -1,5 +1,5 @@
 import {InputItem} from "./base";
-import {deep_copy} from "../../utils"
+import {deep_copy, make_set} from "../../utils"
 
 const options_tpl = `
 {{#options}}
@@ -54,16 +54,9 @@ export class Select extends InputItem {
             opts.eq(idx).val(JSON.stringify(options[idx].value));
 
         // 将额外的html参数加到input标签上
-        const ignore_keys = {
-            'type': '',
-            'label': '',
-            'invalid_feedback': '',
-            'valid_feedback': '',
-            'help_text': '',
-            'options': '',
-            'datalist': '',
-            'multiple': ''
-        };
+        const ignore_keys = make_set(['type', 'label', 'invalid_feedback', 'valid_feedback', 'help_text',
+            'options', 'datalist', 'multiple', 'onchange', 'onblur'])
+
         for (let key in this.spec) {
             if (key in ignore_keys) continue;
             input_elem.attr(key, this.spec[key]);

+ 2 - 1
webiojs/src/models/input/textarea.ts

@@ -57,7 +57,8 @@ export class Textarea extends InputItem {
         }
 
         // 将额外的html参数加到input标签上
-        const ignore_keys = make_set(['value', 'type', 'label', 'invalid_feedback', 'valid_feedback', 'help_text', 'rows', 'code']);
+        const ignore_keys = make_set(['value', 'type', 'label', 'invalid_feedback', 'valid_feedback',
+            'help_text', 'rows', 'code', 'onchange']);
         for (let key in this.spec) {
             if (key in ignore_keys) continue;
             input_elem.attr(key, this.spec[key]);