IE附加div被附加,这不是我的代码的一部分

时间:2018-04-17 11:30:35

标签: html internet-explorer polyfills debounce

我在IE浏览器的网站上遇到了一个奇怪的问题。额外的div被附加到我的DOM并且不是我的代码库的一部分。

这不会发生在Firefox,Chrome和Safari上。

下面是在IE(EDGE)上的DOM中附加的额外div

<div style="margin: 0px; padding: 0px; border: 0px currentColor; border-image: none; width: 1349px; height: 74.99px; font-size: 1em; float: none; position: static; border-spacing: 0;"></div>

有没有人遇到过这个问题?

刚发现这个div是使用polyfill创建的,代码如下

        Stickyfill.addOne(document.querySelector('.main-header'));

现在在窗口调整大小时我有一个事件调整大小,它使用去抖来保持回调的执行。请参考以下代码

const header = document.querySelector('.main-header');
const menuContainer = header.querySelector('.header-nav');

function setTouchMenuHeight() {
  const height = window.innerHeight;
  menuContainer.style.height = bp('<=md') ? `${height}px` : 'auto';
}

setTouchMenuHeight();

window.addEventListener('resize', debounce(setTouchMenuHeight, 150), false);

0 个答案:

没有答案