Browse Source

let args=None (the default) include all attributes of all arguments

Falko Schindler 1 năm trước cách đây
mục cha
commit
e5b1e8524a
2 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 1 1
      nicegui/element.py
  2. 2 2
      nicegui/templates/index.html

+ 1 - 1
nicegui/element.py

@@ -224,7 +224,7 @@ class Element(Visibility):
             listener = EventListener(
                 element_id=self.id,
                 type=type,
-                args=[args] if args is None or args == [] or isinstance(args[0], str) else args,
+                args=[args] if args and isinstance(args[0], str) else args,
                 handler=handler,
                 throttle=throttle,
                 leading_events=leading_events,

+ 2 - 2
nicegui/templates/index.html

@@ -47,14 +47,14 @@
       function stringifyEventArgs(args, event_args) {
         const result = [];
         args.forEach((arg, i) => {
-          if (i >= event_args.length) return;
+          if (event_args !== null && i >= event_args.length) return;
           let filtered = {};
           if (typeof arg !== 'object' || arg === null || Array.isArray(arg)) {
             filtered = arg;
           }
           else {
             for (let k in arg) {
-              if (event_args[i] === null || event_args[i].includes(k)) {
+              if (event_args === null || event_args[i] === null || event_args[i].includes(k)) {
                 filtered[k] = arg[k];
               }
             }