fix: get_by_id层级id查找——精确匹配+后缀兜底+CSS.escape,修复urlwidget replace target静默miss(世界/场景/实体等创建导入点击无反应根因)

This commit is contained in:
pipeline-agent 2026-08-30 13:03:58 +08:00 committed by yumoqing
parent 47b08371aa
commit b7b85e063f
2 changed files with 7 additions and 3 deletions

View File

@ -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);

View File

@ -37,7 +37,7 @@
<script type="module"
src="{{entire_url('/bricks/3parties/model-viewer.min.js')}}">
</script>
<script src="{{entire_url('/bricks/bricks.js')}}?v={% if assets_ver %}{{assets_ver()}}{% else %}20260829a{% endif %}"></script>
<script src="{{entire_url('/bricks/bricks.js')}}?v={% if assets_ver %}{{assets_ver()}}{% else %}20260830a{% endif %}"></script>
{% for myjs in jsfiles() %}
<script src="{{entire_url(myjs)}}{% if assets_ver %}?v={{assets_ver()}}{% endif %}"></script>
{% endfor %}