ソースを参照

maint: check anchor exist when handle `scroll_to` command

wangweimin 5 年 前
コミット
8bb76a25b6
1 ファイル変更3 行追加1 行削除
  1. 3 1
      pywebio/html/js/pywebio.js

+ 3 - 1
pywebio/html/js/pywebio.js

@@ -246,7 +246,9 @@
             this.container_elem.find(`#${msg.spec.clear_after}~*`).remove();
         if (msg.spec.scroll_to !== undefined) {
             var target = $(`#${msg.spec.scroll_to}`);
-            if (OutputFixedHeight) {
+            if (!target.length) {
+                console.error(`Anchor ${msg.spec.scroll_to} not found`);
+            } else if (OutputFixedHeight) {
                 box_scroll_to(target, this.container_parent, msg.spec.position);
             } else {
                 body_scroll_to(target, msg.spec.position);