Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

图片懒加载会影响内联脚本字符串中的<img>元素 #986

Open
3 tasks done
lingrottin opened this issue Jul 31, 2023 · 0 comments
Open
3 tasks done

图片懒加载会影响内联脚本字符串中的<img>元素 #986

lingrottin opened this issue Jul 31, 2023 · 0 comments
Labels
🐛 bug Unexpected problem or unintended behavior

Comments

@lingrottin
Copy link

请确认

  • 是当前最新的 Release 版本
  • 本地 hexo clean && hexo s,并且清除浏览器缓存,仍可复现
  • 已经排除是其他 Hexo 插件影响

Bug 描述

Markdown 文件中使用 <script> 内联脚本时,使用 ` 括起来的模板字符串中包含 html 元素的,里面的 img 元素被粗暴地加上懒加载设置。

复现步骤

该 Bug 复现步骤如下:

  1. 启用懒加载功能
  2. 在页面中包含类似于这样的代码
<script>
    'use strict';
    (function(){
        let makeLinkItem=(element)=>{
            element.innerHTML=`
            <a href="${element.getAttribute("url")}">
            <div class="col-4 col-md-6 col-sm-12 linkitem">
                <div>
                    <img src="${element.getAttribute("image")}" class="linkitem-img" />
                </div>
                <div class="linkitem-txt">
                <div>
                    <span class="linkitem-title">${element.getAttribute("title")}</span>
                </div>
                <div><span>${element.getAttribute("desc")}</span></div>
                </div>
            </div>
            </a>`;
            return;
        }
        Array
            .from(document.getElementsByTagName("link-item"))
            .forEach((element)=>makeLinkItem(element));
    })();
</script>

截图

源文件中的代码:
image
被影响后的页面代码:
image

@lingrottin lingrottin added the 🐛 bug Unexpected problem or unintended behavior label Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

1 participant