mipengine / mip2

MIP (移动网页加速器)通过优化网页JS、控制资源加载顺序,达到加速网页的效果。
https://www.mipengine.org/
MIT License
184 stars 49 forks source link

【项目-async 实验推进】小说页面翻页中有页面头部空白过多 #525

Closed gaoshan003 closed 5 years ago

gaoshan003 commented 5 years ago

BUG 描述 小说页面翻页中有页面头部空白过多 https://psfehttps3.baidu.com:8443/wishwing/c/s/wenxue.m.iqiyi.com/act/nocache/mipReader-18l2h9t25p-18l2zsz5rb.html%3Fbaiduvs%3D222623839%26page%3D1?novel=1&word=&title=&lid=7807845383624309869&referlid=7807845383624309869&ms=1&frsrcid=5064&frorder=2 image

复现步骤 重新复现 Bug 的步骤

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

期望结果 清晰和准确的描述你期望的结果

截图 如果合适,添加问题相关的截图

环境及版本信息:

其他信息 其他补充信息

yenshih commented 5 years ago

由于 async,mip 核心插入组件样式时,mip.css 的 DOM 可能还未生成,需要改成

var mipCssLink

function createStyleElement () {
  var styleElement = document.createElement('style');
  styleElement.type = 'text/css';
  if (!mipCssLink) {
    mipCssLink = head.querySelector('link[rel=stylesheet][href*="/mip.css"]')
  }
  head.insertBefore(styleElement, mipCssLink && mipCssLink.nextSibling || head.firstChild);
  return styleElement
}

@clark-t mip-components-webpack-helpers 也需要同步