Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

An exception occurred when parsing an unclosed label using htm, but no error was reported.This leads to the wrong virtual dom object

未關閉
#122 5 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
javascript
領域
frontend

研究方向

首先,使用 htm.bind(h) 執行提供的 JavaScript 重現程式碼,並將其虛擬 DOM 輸出與預期的 JSON 進行比較。追蹤 tagged template 如何解析未閉合的 meta 和 link 元素;當這些元素仍保持自閉合,且 head 的子元素保留所示結構而沒有未回報的解析錯誤時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

discussion question

An exception occurred when parsing an unclosed label using htm, but no error was reported.

This leads to the wrong virtual dom object.

An exception occurred when parsing an unclosed label with "htm", but no error was reported.

This resulted in the wrong "virtual dom" object.

(async () => {
    function h(type, props, ...children) {
        return {
            type,
            props,
            children
        };
    }
    const {default: htm} = await import('https://unpkg.com/htm?module');
    const html = htm.bind(h);
    return html;
})().then(html => {
    return html`
    <head>
      <meta charset="utf-8" >
      <meta name="viewport" content="width=device-width,initial-scale=1" >
      <meta name="theme-color" content="#ffffff" >
      <title>masx200的github主页-首页</title>
      <!--[if IE]>
        <script src="https://cdn.bootcss.com/babel-polyfill/7.4.4/polyfill.min.js"></script>
      <![endif]-->
      <script
        nomodule=""
        src="https://cdn.jsdelivr.net/gh/masx200/webpack-react-vue-spa-awesome-config@2.4.0/lib/polyfill.min.js"
      ></script>
      <link
        href="https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/main.b9c7ffd191cff11a9b96.css"
        rel="stylesheet"
      >
      <script
        charset="utf-8"
        src="https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.6.c2cea2c684fac63ffae0.js"
      ></script>
      <script
        charset="utf-8"
        src="https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.22.ca40a5fe169fbc33ccf0.js"
      ></script>
      <script
        charset="utf-8"
        src="https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.0.1284ce7c8750a8cfed29.js"
      ></script>
      <script
        charset="utf-8"
        src="https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.13.9d669a3554ec48651e33.js"
      ></script>
      <script
        charset="utf-8"
        src="https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.14.64cca74158382392b422.js"
      ></script>
    </head>
  `;
}).then(temp1 => {
    console.log(JSON.stringify(temp1, null, 4));
});



The 'meta' and 'link' tags above are not closed

The 'meta' and 'link' tags above are not closed

An exception occurred !

[
    "meta",
    {
        "name": "theme-color",
        "content": "#ffffff"
    },
    {
        "type": "title",
        "props": null,
        "children": [
            "masx200的github主页-首页"
        ]
    },
    {
        "type": "script",
        "props": {
            "nomodule": "",
            "src": "https://cdn.jsdelivr.net/gh/masx200/webpack-react-vue-spa-awesome-config@2.4.0/lib/polyfill.min.js"
        },
        "children": []
    },
    {
        "type": "link",
        "props": {
            "href": "https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/main.b9c7ffd191cff11a9b96.css",
            "rel": "stylesheet"
        },
        "children": [
            {
                "type": "script",
                "props": {
                    "charset": "utf-8",
                    "src": "https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.6.c2cea2c684fac63ffae0.js"
                },
                "children": []
            },
            {
                "type": "script",
                "props": {
                    "charset": "utf-8",
                    "src": "https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.22.ca40a5fe169fbc33ccf0.js"
                },
                "children": []
            },
            {
                "type": "script",
                "props": {
                    "charset": "utf-8",
                    "src": "https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.0.1284ce7c8750a8cfed29.js"
                },
                "children": []
            },
            {
                "type": "script",
                "props": {
                    "charset": "utf-8",
                    "src": "https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.13.9d669a3554ec48651e33.js"
                },
                "children": []
            },
            {
                "type": "script",
                "props": {
                    "charset": "utf-8",
                    "src": "https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.14.64cca74158382392b422.js"
                },
                "children": []
            }
        ]
    }
]

The correct output should look like this.

The correct output should look like this.

{
    "type": "head",
    "props": null,
    "children": [
        {
            "type": "meta",
            "props": {
                "charset": "utf-8"
            },
            "children": []
        },
        {
            "type": "meta",
            "props": {
                "name": "viewport",
                "content": "width=device-width,initial-scale=1"
            },
            "children": []
        },
        {
            "type": "meta",
            "props": {
                "name": "theme-color",
                "content": "#ffffff"
            },
            "children": []
        },
        {
            "type": "title",
            "props": null,
            "children": [
                "masx200的github主页-首页"
            ]
        },
        {
            "type": "script",
            "props": {
                "nomodule": "",
                "src": "https://cdn.jsdelivr.net/gh/masx200/webpack-react-vue-spa-awesome-config@2.4.0/lib/polyfill.min.js"
            },
            "children": []
        },
        {
            "type": "link",
            "props": {
                "href": "https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/main.b9c7ffd191cff11a9b96.css",
                "rel": "stylesheet"
            },
            "children": []
        },
        {
            "type": "script",
            "props": {
                "charset": "utf-8",
                "src": "https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.6.c2cea2c684fac63ffae0.js"
            },
            "children": []
        },
        {
            "type": "script",
            "props": {
                "charset": "utf-8",
                "src": "https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.22.ca40a5fe169fbc33ccf0.js"
            },
            "children": []
        },
        {
            "type": "script",
            "props": {
                "charset": "utf-8",
                "src": "https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.0.1284ce7c8750a8cfed29.js"
            },
            "children": []
        },
        {
            "type": "script",
            "props": {
                "charset": "utf-8",
                "src": "https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.13.9d669a3554ec48651e33.js"
            },
            "children": []
        },
        {
            "type": "script",
            "props": {
                "charset": "utf-8",
                "src": "https://cdn.jsdelivr.net/gh/masx200/masx200.github.io@4.3.3/chunk.14.64cca74158382392b422.js"
            },
            "children": []
        }
    ]
}
主要語言
JavaScript
星號
9k
分支
181
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

developit/htm 的其他 Issue

查看 developit/htm 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。