From 23bf960a2a740bf5916010a6e29138d93b7cea87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Thu, 18 Jan 2024 13:38:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(table):=20=E4=BF=AE=E5=A4=8D=20Chrome=20Dev?= =?UTF-8?q?Tools=20=E5=AE=A1=E6=9F=A5=20iframe=20=E4=B8=AD=20table=20?= =?UTF-8?q?=E5=85=83=E7=B4=A0=E6=97=B6=E5=AF=BC=E8=87=B4=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=B4=A9=E6=BA=83=E7=9A=84=E9=97=AE=E9=A2=98=20(#1571)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/modules/table.js b/src/modules/table.js index d3c8f515..871615b2 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -1757,7 +1757,24 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ lay.getStyleRules(style, function(item){ if (item.selectorText === ('.laytable-cell-'+ key)) { - return callback(item), true; + callback(item); + + /* 以下代码为防止 Chrome DevTools 审查 iframe 中的 table 元素时出现的页面崩溃 + * closes https://gitee.com/layui/layui/issues/I8N08M + * 具体原因不明,可能是初始操作 cssRules 触发了 DevTools inspect 的解析报错 + * 后续若浏览器本身修复了该问题,下述补丁也将会剔除 + */ + (function PatcheToCssRulesInDevTools(){ + if (self === parent) return; + var input = lay.elem('input', { + style: 'position: absolute; left: 0; top: 0; opacity: 0.01;' + }); + document.body.appendChild(input); + input.focus(); + document.body.removeChild(input); + })(); + + return true; } }); };