HM-71. Доработки таблицы логов. Универсальной таблице добавлена возможность переопределять рендер строк и заголовков (#31)

This commit is contained in:
Nikolay
2020-07-25 14:23:52 +03:00
committed by GitHub
parent c93a1b8ddb
commit c425ffea45
19 changed files with 231 additions and 63 deletions

View File

@ -26,15 +26,25 @@ class Component extends EmitService {
constructor (mainNodeSelector, parentNode) {
super();
const content = document.querySelector(mainNodeSelector).content;
if (content.children.length > 1) {
const message = '<template> должен содержать только один элемент children';
throw new Error(message);
if (!mainNodeSelector && !parentNode) {
throw new Error('Компонент должен содержать хотябы селектор или родительский Node');
}
this.mainNode = content.firstElementChild.cloneNode(true);
if (parentNode) {
parentNode.appendChild(this.mainNode);
if (mainNodeSelector) {
const content = document.querySelector(mainNodeSelector).content;
if (content.children.length > 1) {
const message = '<template> должен содержать только один элемент children';
throw new Error(message);
}
this.mainNode = content.firstElementChild.cloneNode(true);
if (parentNode) {
parentNode.appendChild(this.mainNode);
}
} else {
this.mainNode = parentNode;
}
this._listeners = [];
this._events = {};
this._isAlive = true;