Proposal: Rework internal html representation and diff logic
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 20/100
- Issue 类型
- 重构
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript
- 领域
- tooling
调研方向
未指定任何文件、测试或入口点。首先定位当前的 HTML 表示和差异计算代码,然后确定所提议的节点结构和报告生成变更的范围;完成这项工作需要达成一致的设计,并完成相应的实现和测试。
由索引模型根据 Issue 内容生成。
描述
I think we should use posthtml-like (bemjson-like) structure for internal representation to make diff calculation process cleaner and more flexible.
Current reports are non-informative on big projects.
Current way we comparing html documents leak on big files and don't feel quotes in attributes.
That's why we should think about core code refactoring.
Representation proposal
HtmlNode {
meta: MetaData, // Different meta data, raw string, another helpful data
tag: String,
classList: ClassesCollection, // Set of classes
attrs: Object<String, HtmlAttr>, // Map of attributes with attrs meta info like quote types
//? dataAttrs: Object<String, HtmlAttr>, // Map of data attributes
content: Array<TextNode, CommentNode, HtmlNode>
}
Samples proposal
<button class="button2" data-bem='{"button2":{}}'></button2>
→
{ meta: { diff: 'subset' }, tag: 'button', classList: ['button2'] }
Report proposal
(Something like https://github.com/chaijs/deep-eql mixed with https://github.com/debitoor/chai-subset)
/x/path
- tag: 'button'
+ tag: 'button2'
.or .selector
+ attrs.missed: 'attr'
button.or like.or__that
+ classList[2]: 'missed-class'
Futher possible features
- More accurate comparing methods where it needs (#144, #146).
- More clean diff calculation logic and testing possibilities (#139, #136, #127).
- HtmlNode can achieve additional fields to compare like
bemEntitieswith a set ofBemjsonNodesotBemEntityNames. - etc.
- 主要语言
- JavaScript
- 星标
- 217
- 派生
- 46
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
bem/html-differ 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 35/100
bem/html-differ#175 ·
-
coa dependency seems broken可能已有人在做 @flip111 于 1717 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 35/100
bem/html-differ#173 ·
-
难度 2/5 1-3 小时 新手友好度 35/100
bem/html-differ#171 · 1 条评论 · 3 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 35/100
bem/html-differ#170 · 2 条评论 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 35/100
bem/html-differ#169 · 1 条评论 ·
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 76/100
521xueweihan/HelloGitHub#3939 ·
-
难度 1/5 1 小时以内 新手友好度 84/100
维护者通常 1 天内回复
-
needs-website-changes
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
[Bug] critique requires the detector on native targets, but audit.native.md says it does not apply未关闭needs triage
难度 2/5 1-3 小时 新手友好度 78/100
pbakaus/impeccable#1017 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复