move el with the publics

This commit is contained in:
Bruno Windels 2020-04-29 19:12:48 +02:00
parent 6a9315e70a
commit 2c8c1eb767

View file

@ -181,24 +181,6 @@ class TemplateBuilder {
return node; return node;
} }
el(name, attributes, children) {
if (attributes && isChildren(attributes)) {
children = attributes;
attributes = null;
}
const node = document.createElement(name);
if (attributes) {
this._setNodeAttributes(node, attributes);
}
if (children) {
this._setNodeChildren(node, children);
}
return node;
}
_setNodeAttributes(node, attributes) { _setNodeAttributes(node, attributes) {
for(let [key, value] of Object.entries(attributes)) { for(let [key, value] of Object.entries(attributes)) {
const isFn = typeof value === "function"; const isFn = typeof value === "function";
@ -255,6 +237,24 @@ class TemplateBuilder {
return node; return node;
} }
el(name, attributes, children) {
if (attributes && isChildren(attributes)) {
children = attributes;
attributes = null;
}
const node = document.createElement(name);
if (attributes) {
this._setNodeAttributes(node, attributes);
}
if (children) {
this._setNodeChildren(node, children);
}
return node;
}
// this insert a view, and is not a view factory for `if`, so returns the root element to insert in the template // this insert a view, and is not a view factory for `if`, so returns the root element to insert in the template
// you should not call t.view() and not use the result (e.g. attach the result to the template DOM tree). // you should not call t.view() and not use the result (e.g. attach the result to the template DOM tree).
view(view) { view(view) {