mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
move el with the publics
This commit is contained in:
parent
6a9315e70a
commit
2c8c1eb767
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user