Gurigraphics / DOMinus.js

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

Class/function wrapping #8

Closed thipages closed 5 years ago

thipages commented 5 years ago

Hi, may I suggest you to wrap the entire code in a class/function Dominus for example so that DOM, MOD UTILS and HTML will not be global anymore?

Doing this, the sample example may look like this

var dominus = new Dominus();
var HTML = dominus.HTML();
HTML.element = {
  tag: "div",
  id: "element", 
  html: "Hello World"
}
dominus.add("element", "#app")

It is a bit more verbose...

Gurigraphics commented 5 years ago

Yes. Before creating (new Dominus ) the idea is eliminate the dependency of the Observable-slim. Because also there is much unused there.

And also move everything to paradigma "convention over configuration". One simple single way of doing things.

thipages commented 5 years ago

I would hesitate between

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

and

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

the second is more verbose but clearer from my point of view

thipages commented 5 years ago

also, I am not sure that ids are necessary

thipages commented 5 years ago

for info and about observable-slim, the code was updated to version 0.14 Major performance overhaul for large arrays of objects

Gurigraphics commented 5 years ago

In the beginning it was so:

"html:  "HTML.header_content"

So I simplified it.

html: header_content

And it can not be an object.

html: HTML.header_content

Must be string

html: "HTML.header_content"

Otherwise you change the object and it does not change. Because "html" was set to the previous value. Like:

var x  = 0
var y = {
 html : x
}
x = 2
Console.log( y.html ) // 0

ID, I think it is not necessary. It continued because the rule id = object_name came later in DOM.remove.

thipages commented 5 years ago

Clear. Thank you

Gurigraphics commented 5 years ago

Ready https://github.com/Gurigraphics/DOMinus.js/issues/11