From b7b85e063f55eb5055b9440c81735edf472e867e Mon Sep 17 00:00:00 2001 From: pipeline-agent Date: Sun, 30 Aug 2026 13:03:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20get=5Fby=5Fid=E5=B1=82=E7=BA=A7id?= =?UTF-8?q?=E6=9F=A5=E6=89=BE=E2=80=94=E2=80=94=E7=B2=BE=E7=A1=AE=E5=8C=B9?= =?UTF-8?q?=E9=85=8D+=E5=90=8E=E7=BC=80=E5=85=9C=E5=BA=95+CSS.escape?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8Durlwidget=20replace=20target?= =?UTF-8?q?=E9=9D=99=E9=BB=98miss=EF=BC=88=E4=B8=96=E7=95=8C/=E5=9C=BA?= =?UTF-8?q?=E6=99=AF/=E5=AE=9E=E4=BD=93=E7=AD=89=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E7=82=B9=E5=87=BB=E6=97=A0=E5=8F=8D=E5=BA=94?= =?UTF-8?q?=E6=A0=B9=E5=9B=A0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bricks/bricks.js | 8 ++++++-- bricks/header.tmpl | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bricks/bricks.js b/bricks/bricks.js index 5ab7fcd..7d6299e 100644 --- a/bricks/bricks.js +++ b/bricks/bricks.js @@ -614,10 +614,14 @@ bricks.getWidgetById = function(idset, from_widget){ } var el = fromw.dom_element; var nel; + // id 可能是层级路径的末段(DOM id 为完整路径如 app.world_content), + // 先精确匹配,再按 ".末段" 后缀兜底;CSS.escape 防点号被当 class 选择器 + var selExact = '#' + (window.CSS && CSS.escape ? CSS.escape(id) : id); + var selSuffix = '[id$=".' + (window.CSS && CSS.escape ? CSS.escape(id) : id) + '"]'; if(downward ){ - nel = el.querySelector('#' + id); + nel = el.querySelector(selExact) || el.querySelector(selSuffix); } else { - nel = el.closest('#' + id); + nel = el.closest(selExact) || el.closest(selSuffix); } if (!nel) { console.log('get_by_id() return null',id, fromw, downward); diff --git a/bricks/header.tmpl b/bricks/header.tmpl index f82c990..e4074c1 100644 --- a/bricks/header.tmpl +++ b/bricks/header.tmpl @@ -37,7 +37,7 @@ - + {% for myjs in jsfiles() %} {% endfor %}