Gurigraphics / DOMinus.js

DOMinus.js is a reactive data binding library that turn HTML irrelevant.
4 stars 1 forks source link

Different syntax between parent and children #4

Closed thipages closed 5 years ago

thipages commented 5 years ago

Hi, What is the reason why of proposing two different syntax for parent and children

Parent (with attrs)

HTML.header = {
tag: "ul", 
attrs: { id: "header", class: "myClass", style: "color:red" },
html: "header_content"  
}

children (without attrs)

HTML.header_content = [
 { tag:"li", id: "header_content_1", html: "0", class: "hide" },  
 { tag:"li", id: "header_content_2", html: "1", class: "hide" },
] 

Why not writing parent like this?

HTML.header = {
  tag: "ul", 
  id: "header",
  class: "myClass",
  style: "color:red",
  html: "header_content"  
}

Thank you

Gurigraphics commented 5 years ago

I started using:

HTML.header = {
tag: "ul", 
attrs: { id: "header" },
html: "header_content"  
}

And the child was not good at writing:

HTML.header_content = [
 { tag:"li", attrs: { id: "header" }, html: "0" },  
 { tag:"li", attrs: { id: "header" }, html: "1" },
] 

So I simplified it. It would be useful if you shared the same attributes, but this is not the case. Then, also simplifying the parent is same the next step to progress.

Gurigraphics commented 5 years ago

Now accept both syntax. https://github.com/Gurigraphics/DOMinus.js/issues/6

thipages commented 5 years ago

Well done.