Merged svghmi
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Tue, 23 Mar 2021 05:15:19 +0100
branchsvghmi
changeset 3196 f1049e4df866
parent 3194 490fbf870f42 (current diff)
parent 3195 cdd2a032b424 (diff)
child 3197 0f41c1e2c121
child 3198 d9c8f8789fc8
Merged
--- a/svghmi/gen_index_xhtml.xslt	Tue Mar 23 05:13:18 2021 +0100
+++ b/svghmi/gen_index_xhtml.xslt	Tue Mar 23 05:15:19 2021 +0100
@@ -4607,49 +4607,55 @@
 </xsl:text>
     <xsl:text>        this.abort_controller = new AbortController();
 </xsl:text>
-    <xsl:text>        const query = {
-</xsl:text>
-    <xsl:text>            args: this.args,
-</xsl:text>
-    <xsl:text>            range: this.cache[1],
-</xsl:text>
-    <xsl:text>            position: this.cache[2],
-</xsl:text>
-    <xsl:text>            visible: this.visible,
-</xsl:text>
-    <xsl:text>            extra: this.cache.slice(4),
-</xsl:text>
-    <xsl:text>            options: opt
-</xsl:text>
-    <xsl:text>        };
-</xsl:text>
-    <xsl:text>
-</xsl:text>
-    <xsl:text>        const options = {
-</xsl:text>
-    <xsl:text>             method: 'POST',
-</xsl:text>
-    <xsl:text>             body: JSON.stringify(query),
-</xsl:text>
-    <xsl:text>             headers: {'Content-Type': 'application/json'},
-</xsl:text>
-    <xsl:text>             signal: this.abort_controller.signal
-</xsl:text>
-    <xsl:text>        };
-</xsl:text>
-    <xsl:text>
-</xsl:text>
-    <xsl:text>        return fetch(this.args[0], options)
-</xsl:text>
-    <xsl:text>                .then(this.handle_http_response_bound)
-</xsl:text>
-    <xsl:text>                .then(this.spread_json_data_bound)
-</xsl:text>
-    <xsl:text>                .catch(this.fetch_error_bound);
-</xsl:text>
-    <xsl:text>
-</xsl:text>
-    <xsl:text>    }
+    <xsl:text>        return Promise.resolve().then(() =&gt; {
+</xsl:text>
+    <xsl:text>
+</xsl:text>
+    <xsl:text>            const query = {
+</xsl:text>
+    <xsl:text>                args: this.args,
+</xsl:text>
+    <xsl:text>                range: this.cache[1],
+</xsl:text>
+    <xsl:text>                position: this.cache[2],
+</xsl:text>
+    <xsl:text>                visible: this.visible,
+</xsl:text>
+    <xsl:text>                extra: this.cache.slice(4),
+</xsl:text>
+    <xsl:text>                options: opt
+</xsl:text>
+    <xsl:text>            };
+</xsl:text>
+    <xsl:text>
+</xsl:text>
+    <xsl:text>            const options = {
+</xsl:text>
+    <xsl:text>                 method: 'POST',
+</xsl:text>
+    <xsl:text>                 body: JSON.stringify(query),
+</xsl:text>
+    <xsl:text>                 headers: {'Content-Type': 'application/json'},
+</xsl:text>
+    <xsl:text>                 signal: this.abort_controller.signal
+</xsl:text>
+    <xsl:text>            };
+</xsl:text>
+    <xsl:text>
+</xsl:text>
+    <xsl:text>            return fetch(this.args[0], options)
+</xsl:text>
+    <xsl:text>                    .then(this.handle_http_response_bound)
+</xsl:text>
+    <xsl:text>                    .then(this.spread_json_data_bound)
+</xsl:text>
+    <xsl:text>                    .catch(this.fetch_error_bound);
+</xsl:text>
+    <xsl:text>        });
+</xsl:text>
+    <xsl:text>    }
+</xsl:text>
+    <xsl:text>
 </xsl:text>
     <xsl:text>    unsub(){
 </xsl:text>
--- a/svghmi/widget_jsontable.ysl2	Tue Mar 23 05:13:18 2021 +0100
+++ b/svghmi/widget_jsontable.ysl2	Tue Mar 23 05:15:19 2021 +0100
@@ -25,28 +25,31 @@
 
         do_http_request(...opt) {
             this.abort_controller = new AbortController();
-            const query = {
-                args: this.args,
-                range: this.cache[1],
-                position: this.cache[2],
-                visible: this.visible,
-                extra: this.cache.slice(4),
-                options: opt
-            };
-
-            const options = {
-                 method: 'POST',
-                 body: JSON.stringify(query),
-                 headers: {'Content-Type': 'application/json'},
-                 signal: this.abort_controller.signal
-            };
-
-            return fetch(this.args[0], options)
-                    .then(this.handle_http_response_bound)
-                    .then(this.spread_json_data_bound)
-                    .catch(this.fetch_error_bound);
-
-        }
+            return Promise.resolve().then(() => {
+
+                const query = {
+                    args: this.args,
+                    range: this.cache[1],
+                    position: this.cache[2],
+                    visible: this.visible,
+                    extra: this.cache.slice(4),
+                    options: opt
+                };
+
+                const options = {
+                     method: 'POST',
+                     body: JSON.stringify(query),
+                     headers: {'Content-Type': 'application/json'},
+                     signal: this.abort_controller.signal
+                };
+
+                return fetch(this.args[0], options)
+                        .then(this.handle_http_response_bound)
+                        .then(this.spread_json_data_bound)
+                        .catch(this.fetch_error_bound);
+            });
+        }
+
         unsub(){
             this.abort_controller.abort();
             super.unsub();