fix(table): 修复 Chrome DevTools 审查 iframe 中 table 元素时导致页面崩溃的问题 (#1571)

pull/1584/head
贤心 2024-01-18 13:38:21 +08:00 committed by GitHub
parent 90000f39f6
commit 23bf960a2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 1 deletions

View File

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