@alexgyver/component 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/component.js +15 -6
- package/package.json +1 -1
package/component.js
CHANGED
|
@@ -67,7 +67,7 @@ export class Component {
|
|
|
67
67
|
*/
|
|
68
68
|
constructor(tag, data = {}, style = null, id = null, ext = false) {
|
|
69
69
|
data.context = this;
|
|
70
|
-
this.$root = Component.
|
|
70
|
+
this.$root = Component.makeStyled(tag, data, style, id, ext);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/*
|
|
@@ -91,12 +91,8 @@ export class Component {
|
|
|
91
91
|
* Создать компонент
|
|
92
92
|
* @param {string} tag html tag элемента
|
|
93
93
|
* @param {object} data параметры
|
|
94
|
-
* @param {string|array} style стили в виде css строки или [ 'class', ['color: red', 'padding: 0'], ... ]
|
|
95
|
-
* @param {string|this} id уникальный id стиля
|
|
96
|
-
* @param {boolean} ext внешний стиль - может быть удалён по id
|
|
97
94
|
*/
|
|
98
|
-
static make(tag, data = {}
|
|
99
|
-
Sheet.addStyle(style, id, ext);
|
|
95
|
+
static make(tag, data = {}) {
|
|
100
96
|
if (!tag || typeof data !== 'object') return null;
|
|
101
97
|
if (data instanceof Node) return data;
|
|
102
98
|
|
|
@@ -141,6 +137,19 @@ export class Component {
|
|
|
141
137
|
return $el;
|
|
142
138
|
}
|
|
143
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Создать компонент со стилем
|
|
142
|
+
* @param {string} tag html tag элемента
|
|
143
|
+
* @param {object} data параметры
|
|
144
|
+
* @param {string|array} style стили в виде css строки или [ 'class', ['color: red', 'padding: 0'], ... ]
|
|
145
|
+
* @param {string|this} id уникальный id стиля
|
|
146
|
+
* @param {boolean} ext внешний стиль - может быть удалён по id
|
|
147
|
+
*/
|
|
148
|
+
static makeStyled(tag, data = {}, style = null, id = null, ext = false) {
|
|
149
|
+
Sheet.addStyle(style, id, ext);
|
|
150
|
+
return Component.make(tag, data);
|
|
151
|
+
}
|
|
152
|
+
|
|
144
153
|
/**
|
|
145
154
|
* Создать массив компонентов из массива объектов конфигурации
|
|
146
155
|
* @param {array} arr массив объектов конфигурации
|