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

Proposal: Rework internal html representation and diff logic #149

Open
qfox opened this issue Jul 7, 2017 · 0 comments
Open

Proposal: Rework internal html representation and diff logic #149

qfox opened this issue Jul 7, 2017 · 0 comments

Comments

@qfox
Copy link
Member

qfox commented Jul 7, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant