@lexriver/dome 1.5.11 → 2.0.1
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/README.md +10 -4
- package/out/{AnimatedArray.d.ts → src/AnimatedArray.d.mts} +29 -29
- package/out/{AnimatedArray.js → src/AnimatedArray.mjs} +52 -51
- package/out/{AnimatedTable.d.ts → src/AnimatedTable.d.mts} +38 -38
- package/out/{AnimatedTable.js → src/AnimatedTable.mjs} +88 -91
- package/out/{AnimatedText.d.ts → src/AnimatedText.d.mts} +13 -13
- package/out/{AnimatedText.js → src/AnimatedText.mjs} +24 -24
- package/out/{Animation.d.ts → src/Animation.d.mts} +4 -4
- package/out/{temp-test.d.ts → src/Animation.mjs} +1 -1
- package/out/{Dome.d.ts → src/Dome.d.mts} +9 -9
- package/out/{Dome.js → src/Dome.mjs} +291 -295
- package/out/{DomeComponent.d.ts → src/DomeComponent.d.mts} +22 -19
- package/out/{DomeComponent.js → src/DomeComponent.mjs} +47 -44
- package/out/{DomeManipulator.d.ts → src/DomeManipulator.d.mts} +48 -48
- package/out/{DomeManipulator.js → src/DomeManipulator.mjs} +329 -329
- package/out/src/DomeRouter.console-test.d.mts +1 -0
- package/out/{DomeRouter.console-test.js → src/DomeRouter.console-test.mjs} +44 -44
- package/out/{DomeRouter.d.ts → src/DomeRouter.d.mts} +32 -30
- package/out/{DomeRouter.js → src/DomeRouter.mjs} +249 -237
- package/out/{LongestCommonSubsequence.d.ts → src/LongestCommonSubsequence.d.mts} +15 -15
- package/out/{LongestCommonSubsequence.js → src/LongestCommonSubsequence.mjs} +164 -164
- package/out/src/index.d.mts +11 -0
- package/out/src/index.mjs +11 -0
- package/out/src/temp-test.d.mts +1 -0
- package/out/{temp-test.js → src/temp-test.mjs} +20 -20
- package/out/vitest.config.d.ts +2 -0
- package/out/vitest.config.js +9 -0
- package/package.json +16 -14
- package/src/{AnimatedArray.ts → AnimatedArray.mts} +3 -3
- package/src/{AnimatedTable.ts → AnimatedTable.mts} +6 -6
- package/src/{AnimatedText.ts → AnimatedText.mts} +4 -4
- package/src/{Animation.ts → Animation.mts} +0 -0
- package/src/{Dome.ts → Dome.mts} +7 -11
- package/src/{DomeComponent.ts → DomeComponent.mts} +3 -3
- package/src/{DomeManipulator.ts → DomeManipulator.mts} +5 -5
- package/src/{DomeRouter.console-test.ts → DomeRouter.console-test.mts} +0 -0
- package/src/{DomeRouter.ts → DomeRouter.mts} +20 -6
- package/src/{LongestCommonSubsequence.ts → LongestCommonSubsequence.mts} +0 -0
- package/src/index.mts +12 -0
- package/src/{temp-test.ts → temp-test.mts} +1 -1
- package/tsconfig.json +57 -60
- package/vitest.config.ts +10 -0
- package/jest.config.js +0 -22
- package/out/Animation.js +0 -0
- package/out/DomeRouter.console-test.d.ts +0 -0
- package/out/index.d.ts +0 -12
- package/out/index.js +0 -14
- package/src/index.ts +0 -14
|
@@ -1,295 +1,291 @@
|
|
|
1
|
-
// inspiration: https://github.com/vadimdemedes/dom-chef/blob/master/index.js
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
'
|
|
29
|
-
'
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
// )
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
//#
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (DataTypes.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (name === '
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
value
|
|
156
|
-
//
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
//
|
|
257
|
-
//
|
|
258
|
-
|
|
259
|
-
//
|
|
260
|
-
//
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
//
|
|
273
|
-
//
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
//
|
|
277
|
-
//
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
export
|
|
292
|
-
createElement: h,
|
|
293
|
-
Fragment: typeof DocumentFragment === 'function' ? DocumentFragment : () => { }
|
|
294
|
-
};
|
|
295
|
-
export default React;
|
|
1
|
+
// inspiration: https://github.com/vadimdemedes/dom-chef/blob/master/index.js
|
|
2
|
+
const svgTagNames = require('svg-tag-names');
|
|
3
|
+
import { DataTypes } from '@lexriver/data-types';
|
|
4
|
+
import { checkIfObservable } from '@lexriver/observable';
|
|
5
|
+
import { DomeManipulator } from './DomeManipulator.mjs';
|
|
6
|
+
const filename = '[Dome]: ';
|
|
7
|
+
//const mountFunctionByNode = new Map<Node, (ref:any)=>void>()
|
|
8
|
+
// https://github.com/jonschlinkert/arr-flatten/blob/master/index.js
|
|
9
|
+
function flattenArray(arr, res = []) {
|
|
10
|
+
var i = 0, cur;
|
|
11
|
+
var len = arr.length;
|
|
12
|
+
for (; i < len; i++) {
|
|
13
|
+
cur = arr[i];
|
|
14
|
+
Array.isArray(cur) ? flattenArray(cur, res) : res.push(cur);
|
|
15
|
+
}
|
|
16
|
+
return res;
|
|
17
|
+
}
|
|
18
|
+
function checkIfNonDimensionalCssName(name) {
|
|
19
|
+
// Copied from Preact
|
|
20
|
+
const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;
|
|
21
|
+
return IS_NON_DIMENSIONAL.test(name);
|
|
22
|
+
}
|
|
23
|
+
const excludeSvgTags = [
|
|
24
|
+
'a',
|
|
25
|
+
'audio',
|
|
26
|
+
'canvas',
|
|
27
|
+
'iframe',
|
|
28
|
+
'script',
|
|
29
|
+
'video'
|
|
30
|
+
];
|
|
31
|
+
const svgTags = svgTagNames.filter(name => !excludeSvgTags.includes(name));
|
|
32
|
+
const isSVG = tagName => svgTags.includes(tagName);
|
|
33
|
+
const setCSSProps = (el, style) => {
|
|
34
|
+
if (DataTypes.isString(style)) {
|
|
35
|
+
el.style = style;
|
|
36
|
+
}
|
|
37
|
+
else if (DataTypes.isObjectWithKeys(style)) {
|
|
38
|
+
Object.keys(style).forEach(name => {
|
|
39
|
+
let value = style[name];
|
|
40
|
+
if (typeof value === 'number' && !checkIfNonDimensionalCssName(name)) {
|
|
41
|
+
value = `${value}px`;
|
|
42
|
+
}
|
|
43
|
+
el.style[name] = value;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const createElement = (tagName) => {
|
|
48
|
+
if (isSVG(tagName)) {
|
|
49
|
+
return document.createElementNS('http://www.w3.org/2000/svg', tagName);
|
|
50
|
+
}
|
|
51
|
+
if (tagName === DocumentFragment) {
|
|
52
|
+
return document.createDocumentFragment();
|
|
53
|
+
}
|
|
54
|
+
return document.createElement(tagName);
|
|
55
|
+
};
|
|
56
|
+
// function subscribeToEventByParam(x:OnEventObject, el:HTMLElement){
|
|
57
|
+
// if(
|
|
58
|
+
// !x.eventName ||
|
|
59
|
+
// Data.isString(x.eventName) == false ||
|
|
60
|
+
// !x.eventReaction ||
|
|
61
|
+
// Data.isFunction(x.eventReaction) == false
|
|
62
|
+
// ){
|
|
63
|
+
// console.error('x=', x, 'el=', el)
|
|
64
|
+
// throw new Error(`Please provide object of type {eventName:string, eventParams:Object, eventReaction:(eventParams, htmlElement)=>void}`)
|
|
65
|
+
// }
|
|
66
|
+
// //DomeEventDispatcher.subscribeToEvent(el, x.eventName, x.eventParams || {}, x.eventReaction)
|
|
67
|
+
// DomeEventDispatcher.subscribeToEvent({
|
|
68
|
+
// eventName: x.eventName,
|
|
69
|
+
// eventParamsFilter: x.eventParams || {},
|
|
70
|
+
// action: x.eventReaction,
|
|
71
|
+
// unsubscribeWhen: () => DomeManipulator.isInDom(el) == false
|
|
72
|
+
// })
|
|
73
|
+
// }
|
|
74
|
+
const build = (tagName, attrs, children) => {
|
|
75
|
+
if (!tagName) {
|
|
76
|
+
console.trace();
|
|
77
|
+
throw new Error('tagName=' + tagName);
|
|
78
|
+
}
|
|
79
|
+
// if(children && typeof children !== 'object'){
|
|
80
|
+
// //console.log('tagName=', tagName, 'attrs=',attrs, 'children=', children)
|
|
81
|
+
// console.log('tagName=', tagName, 'children=', children, 'typeof children=', typeof children)
|
|
82
|
+
// }
|
|
83
|
+
if (tagName == DocumentFragment) {
|
|
84
|
+
//console.warn(filename, 'isDocumentFragment!')
|
|
85
|
+
const el = createElement(tagName);
|
|
86
|
+
el.appendChild(children);
|
|
87
|
+
return el;
|
|
88
|
+
}
|
|
89
|
+
//console.log(filename, 'instaceof=', tagName instanceof DomeComponent)
|
|
90
|
+
//console.log(filename, 'has render=', tagName.render)
|
|
91
|
+
//console.log(filename, 'instanceof Object=', tagName instanceof Object)
|
|
92
|
+
if (tagName.prototype && tagName.prototype['__DomeComponent']) {
|
|
93
|
+
// we have a DomeComponent
|
|
94
|
+
//console.warn('DomeComponent!')
|
|
95
|
+
try {
|
|
96
|
+
const instance = new tagName(attrs, children);
|
|
97
|
+
//console.log('instance=', instance)
|
|
98
|
+
if (instance['render'] && DataTypes.isFunction(instance['render'])) {
|
|
99
|
+
//#region make ref points to instance, not element
|
|
100
|
+
if (attrs.ref && DataTypes.isFunction(attrs.ref)) {
|
|
101
|
+
attrs.ref(instance);
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
instance['init']();
|
|
105
|
+
instance.rootElement = instance['render']();
|
|
106
|
+
//#region subscribe to observable attribute
|
|
107
|
+
for (let attribute of Object.values(attrs)) {
|
|
108
|
+
if (checkIfObservable(attribute)) {
|
|
109
|
+
attribute.eventOnChange.subscribe(() => {
|
|
110
|
+
//this.update()
|
|
111
|
+
instance.scheduleUpdate();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//requestAnimationFrame(() => {
|
|
117
|
+
instance['afterRender']();
|
|
118
|
+
//})
|
|
119
|
+
return instance.rootElement;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
console.error('error while creating DomeComponent class', error);
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (DataTypes.isFunction(tagName)) {
|
|
128
|
+
// call functional component
|
|
129
|
+
return tagName(attrs, children);
|
|
130
|
+
}
|
|
131
|
+
else if (DataTypes.isString(tagName)) {
|
|
132
|
+
const el = createElement(tagName);
|
|
133
|
+
//console.log('lex-dome', 'creating element', el)
|
|
134
|
+
Object.keys(attrs).forEach(name => {
|
|
135
|
+
const value = attrs[name];
|
|
136
|
+
if (name === 'class' || name === 'className' || name === 'cssClasses') {
|
|
137
|
+
//DomeManipulator.setCssClasses(el, value)
|
|
138
|
+
assignDynamicCssClasses(name, value, el);
|
|
139
|
+
}
|
|
140
|
+
else if (name === 'style') {
|
|
141
|
+
setCSSProps(el, value);
|
|
142
|
+
}
|
|
143
|
+
else if (['disabled', 'autocomplete', 'selected', 'checked'].indexOf(name) >= 0) {
|
|
144
|
+
if (attrs[name]) {
|
|
145
|
+
DomeManipulator.setAttribute(el, name, name);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else if (name === 'onCreate' || name === 'ref') {
|
|
149
|
+
if (DataTypes.isFunction(value) == false)
|
|
150
|
+
throw new Error(`Please provide function <${tagName} ${name}={ref => myRef=ref} />`);
|
|
151
|
+
value(el);
|
|
152
|
+
// } else if(name === 'onEvent'){ //TODO: remove this!?
|
|
153
|
+
// // <div onEvent={{eventName:'myCumstomEvent', eventParams:{any:'params',can:'be',here:true}, eventReaction:()=>{}}}>some text for div</div>
|
|
154
|
+
// //#region is Object
|
|
155
|
+
// if(Data.isObjectWithKeys(value)){
|
|
156
|
+
// subscribeToEventByParam(value as OnEventObject, el)
|
|
157
|
+
// return
|
|
158
|
+
// }
|
|
159
|
+
// //#endregion
|
|
160
|
+
// //#region is Array
|
|
161
|
+
// if(Data.isArray(value)){
|
|
162
|
+
// for(let x of value){
|
|
163
|
+
// subscribeToEventByParam(x as OnEventObject, el)
|
|
164
|
+
// }
|
|
165
|
+
// }
|
|
166
|
+
// //#endregion
|
|
167
|
+
}
|
|
168
|
+
else if (name == 'visibleIf') { //TODO: remove this!?
|
|
169
|
+
if (checkIfObservable(value) == false) {
|
|
170
|
+
console.error('value=', value);
|
|
171
|
+
throw new Error('Please provide Observable<boolean> as argument for visibleIf');
|
|
172
|
+
}
|
|
173
|
+
let obs = value;
|
|
174
|
+
obs.eventOnChange.subscribe((isVisible) => {
|
|
175
|
+
if (isVisible) {
|
|
176
|
+
DomeManipulator.unhideElementAsync(el);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
DomeManipulator.hideElementAsync(el);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
setTimeout(() => {
|
|
183
|
+
obs.eventOnChange.triggerAsync(obs.get());
|
|
184
|
+
}, 1);
|
|
185
|
+
}
|
|
186
|
+
else if (name.indexOf('on') === 0 && value) {
|
|
187
|
+
const eventName = name.slice(2).toLowerCase();
|
|
188
|
+
if (DataTypes.isFunction(value) == false) {
|
|
189
|
+
console.error('unable to subscribe for event', eventName, 'listener is not a function', 'element=', el, 'listener=', value);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
//console.log('adding event listener for', el, 'eventName=', eventName, 'value=', value)
|
|
193
|
+
el.addEventListener(eventName, value);
|
|
194
|
+
}
|
|
195
|
+
else if (name === 'innerHtml') {
|
|
196
|
+
el.innerHTML = value;
|
|
197
|
+
}
|
|
198
|
+
else if (name !== 'key' && value !== false) {
|
|
199
|
+
DomeManipulator.setAttribute(el, name, value === true ? '' : value);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
if (!attrs.innerHtml) {
|
|
203
|
+
el.appendChild(children);
|
|
204
|
+
}
|
|
205
|
+
return el;
|
|
206
|
+
}
|
|
207
|
+
else
|
|
208
|
+
throw new Error("not implemented");
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
*
|
|
212
|
+
* @param value
|
|
213
|
+
* @param name
|
|
214
|
+
* @param element
|
|
215
|
+
*/
|
|
216
|
+
function assignDynamicCssClasses(name, value, element) {
|
|
217
|
+
if (DataTypes.isObjectWithKeys(value) == false) {
|
|
218
|
+
DomeManipulator.setCssClasses(element, value);
|
|
219
|
+
return;
|
|
220
|
+
//throw new Error(`Please provide object for ${name}, ex: {class1:true, class2:myVarO}`)
|
|
221
|
+
}
|
|
222
|
+
let resultArray = [];
|
|
223
|
+
for (let [k, v] of Object.entries(value)) {
|
|
224
|
+
if (v === undefined) {
|
|
225
|
+
//skip
|
|
226
|
+
}
|
|
227
|
+
else if (DataTypes.isBoolean(v)) {
|
|
228
|
+
if (v) {
|
|
229
|
+
resultArray.push(k);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else if (checkIfObservable(v)) {
|
|
233
|
+
let o = v;
|
|
234
|
+
o.eventOnChange.subscribe((showThiCssClass) => {
|
|
235
|
+
if (!DomeManipulator.isInDom(element))
|
|
236
|
+
return { unsubscribe: true }; //TODO: test it
|
|
237
|
+
// reassign whole attribute
|
|
238
|
+
DomeManipulator.setCssClasses(element, value);
|
|
239
|
+
});
|
|
240
|
+
if (o.get()) {
|
|
241
|
+
resultArray.push(k);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
console.error(`Please provide classNames as a keys and boolean or Observable<boolean> for values., ex: {class1:true, class2:myVarO}`, 'name=', name, 'value=', value, 'typeof value =', typeof value);
|
|
246
|
+
throw new Error('Wrong value for `class` attribute');
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
DomeManipulator.setCssClasses(element, resultArray); // yes, array of classes is ok here
|
|
250
|
+
}
|
|
251
|
+
export function h(tagName, attrs, ...childrenArgs) {
|
|
252
|
+
// eslint-disable-next-line prefer-rest-params
|
|
253
|
+
//const childrenArgs = [].slice.apply(arguments, [2])
|
|
254
|
+
const children = document.createDocumentFragment();
|
|
255
|
+
//const childArray:any[] = []
|
|
256
|
+
// console.log(filename, 'childrenArgs=', childrenArgs)
|
|
257
|
+
// console.log(filename, 'childrenO=', childrenO)
|
|
258
|
+
// if(tagName === 'hoho'){
|
|
259
|
+
// console.warn(filename, tagName, attrs, ...childrenArgs)
|
|
260
|
+
// }
|
|
261
|
+
flattenArray(childrenArgs).forEach(child => {
|
|
262
|
+
//(childrenArgs).forEach(child => {
|
|
263
|
+
// if(tagName === 'hoho'){
|
|
264
|
+
// console.warn(filename, 'child=', child)
|
|
265
|
+
// }
|
|
266
|
+
if (child instanceof Node) {
|
|
267
|
+
children.appendChild(child);
|
|
268
|
+
//childArray.push(child)
|
|
269
|
+
// const mountFunction = mountFunctionByNode.get(child)
|
|
270
|
+
// if(mountFunction){
|
|
271
|
+
// mountFunction(child)
|
|
272
|
+
// mountFunctionByNode.delete(child)// delete after execution
|
|
273
|
+
// }
|
|
274
|
+
}
|
|
275
|
+
else if (typeof child !== 'boolean' && typeof child !== 'undefined' && child !== null) {
|
|
276
|
+
//console.log('[Dome] child=', child)
|
|
277
|
+
//console.warn(filename, 'text? child=', child)
|
|
278
|
+
children.appendChild(document.createTextNode(child));
|
|
279
|
+
//childArray.push(document.createTextNode(child))
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
//return build(tagName, attrs || {}, children)
|
|
283
|
+
return build(tagName, attrs || {}, children);
|
|
284
|
+
}
|
|
285
|
+
// Improve TypeScript support for DocumentFragment
|
|
286
|
+
// https://github.com/Microsoft/TypeScript/issues/20469
|
|
287
|
+
export const React = {
|
|
288
|
+
createElement: h,
|
|
289
|
+
Fragment: typeof DocumentFragment === 'function' ? DocumentFragment : () => { }
|
|
290
|
+
};
|
|
291
|
+
export default React;
|