`<button>` inside `<select>` closes the select (customizable select)

未关闭 适合新手
#2,579 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
html, javascript, typescript
领域
backend, web-dev

调研方向

阅读 src/Parser.ts,尤其是 openImpliesClose;issue 指出 button 和 formTags 是原因。检查 parser 测试中与 select 和 button 相关的行为,然后调整处理逻辑并运行相关测试。完成标准是:提供的可自定义 select 示例在 HTML 模式下将 button 和 option 保留在 select 内,同时保留 XML 模式。

由索引模型根据 Issue 内容生成。

描述

The HTML spec now allows <button> (with <selectedcontent>) as the first child of <select> for customizable select (whatwg/html#10548, whatwg/html#10310). htmlparser2 closes the <select> as soon as <button> opens.

import { parseDocument } from "htmlparser2";
import render from "dom-serializer";

render(parseDocument(
  "<select><button><selectedcontent></selectedcontent></button><option>A</option></select>"
));
// actual:   <select></select><button><selectedcontent></selectedcontent></button><option>A</option>
// expected: <select><button><selectedcontent></selectedcontent></button><option>A</option></select>

Cause: in openImpliesClose, button maps to formTags, which contains select.

Reproduced with htmlparser2 12.0.0 and current master. With xmlMode: true the structure is preserved.

Originally reported downstream in posthtml/posthtml#408.

主要语言
TypeScript
星标
4.8k
派生
411
平均合并
14 小时 58 分钟
30 天内合并 PR
13

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

fb55/htmlparser2 的其他 Issue

查看 fb55/htmlparser2 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。