fix: 修复 nav 在 IE 中的兼容性问题 (#2415)

* fix(nav): 导航菜单在 IE 中的兼容性问题

* treeTable(test): 添加 IE 测试
pull/2426/head
morning-star 2024-12-20 16:28:15 +08:00 committed by GitHub
parent e0a806449b
commit 0356e805d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 49 additions and 2 deletions

View File

@ -26,6 +26,53 @@
<script src="../src/layui.js"></script>
<script>
// IE8 support
// ES5 15.4.4.19 Array.prototype.map ( callbackfn [ , thisArg ] )
// From https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Map
if (!Array.prototype.map) {
Array.prototype.map = function (fun /*, thisp */) {
if (this === void 0 || this === null) { throw TypeError(); }
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function") { throw TypeError(); }
var res = []; res.length = len;
var thisp = arguments[1], i;
for (i = 0; i < len; i++) {
if (i in t) {
res[i] = fun.call(thisp, t[i], i, t);
}
}
return res;
};
}
// ES5 15.4.4.20 Array.prototype.filter ( callbackfn [ , thisArg ] )
// From https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/Filter
if (!Array.prototype.filter) {
Array.prototype.filter = function (fun /*, thisp */) {
if (this === void 0 || this === null) { throw TypeError(); }
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function") { throw TypeError(); }
var res = [];
var thisp = arguments[1], i;
for (i = 0; i < len; i++) {
if (i in t) {
var val = t[i]; // in case fun mutates this
if (fun.call(thisp, val, i, t)) {
res.push(val);
}
}
}
return res;
};
}
layui.use(['treeTable', 'dropdown', 'layer'], function(){
var treeTable = layui.treeTable;
var dropdown = layui.dropdown;

View File

@ -519,8 +519,8 @@ layui.define('jquery', function(exports){
var itemElem = othis.find('.'+NAV_ITEM);
// hover 滑动效果
var hasBarElem = othis.find('.'+NAV_BAR)[0];
if (hasBarElem) hasBarElem.remove();
var hasBarElem = othis.find('.'+NAV_BAR);
if (hasBarElem[0]) hasBarElem.remove();
othis.append(bar);
( othis.hasClass(NAV_TREE)
? itemElem.find('dd,>.'+ NAV_TITLE)