@lightningjs/blits 1.22.0 → 1.23.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/.github/workflows/run-blits-tests.yml +69 -0
- package/CHANGELOG.md +22 -0
- package/README.md +1 -1
- package/docs/README.md +1 -2
- package/docs/built-in/directives.md +1 -1
- package/docs/built-in/for-loop.md +8 -8
- package/docs/built-in/layout.md +23 -23
- package/docs/components/user_input.md +3 -3
- package/docs/components/utility_methods.md +11 -7
- package/docs/essentials/displaying_images.md +3 -3
- package/docs/essentials/displaying_text.md +3 -3
- package/docs/essentials/element_attributes.md +3 -3
- package/docs/essentials/template_syntax.md +1 -1
- package/docs/getting_started/intro.md +1 -1
- package/docs/plugins/global_app_state.md +2 -2
- package/docs/plugins/language.md +2 -2
- package/docs/plugins/theme.md +1 -1
- package/docs/router/basics.md +4 -4
- package/docs/router/hooks.md +1 -1
- package/docs/transitions_animations/transitions.md +2 -2
- package/index.d.ts +37 -1
- package/package.json +2 -2
- package/src/component/base/index.js +3 -1
- package/src/component/setup/index.js +4 -3
- package/src/component/setup/routes.js +6 -1
- package/src/component.js +24 -7
- package/src/component.test.js +6 -5
- package/src/components/Circle.js +1 -1
- package/src/components/FPScounter.js +1 -1
- package/src/components/RouterView.js +1 -1
- package/src/components/Sprite.js +1 -1
- package/src/lib/codegenerator/generator.js +61 -8
- package/src/lib/codegenerator/generator.test.js +1089 -167
- package/src/lib/eventListeners.js +3 -3
- package/src/lib/precompiler/precompiler.js +2 -3
- package/src/lib/reactivity/effect.js +5 -5
- package/src/lib/reactivity/reactive.js +1 -0
- package/src/lib/reactivityguard/computedprops.js +218 -0
- package/src/lib/symbols.js +1 -0
- package/src/router/router.js +28 -6
- package/vite/index.js +3 -1
- package/vite/preCompiler.js +1 -1
- package/vite/reactivityGuard.js +45 -0
|
@@ -80,11 +80,14 @@ test('The contex key is an object', (assert) => {
|
|
|
80
80
|
|
|
81
81
|
test('Generate render and effect code for an empty template', (assert) => {
|
|
82
82
|
const expectedRender = `
|
|
83
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
83
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
84
84
|
const elms = []
|
|
85
85
|
let componentType
|
|
86
86
|
const rootComponent = component
|
|
87
87
|
let propData
|
|
88
|
+
let slotComponent
|
|
89
|
+
let inSlot = false
|
|
90
|
+
let slotChildCounter = 0
|
|
88
91
|
return elms
|
|
89
92
|
}
|
|
90
93
|
`
|
|
@@ -113,14 +116,20 @@ test('Generate render and effect code for a template with a single simple elemen
|
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
const expectedRender = `
|
|
116
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
119
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
117
120
|
const elms = []
|
|
118
121
|
let componentType
|
|
119
122
|
const rootComponent = component
|
|
120
123
|
let propData
|
|
124
|
+
let slotComponent
|
|
125
|
+
let inSlot = false
|
|
126
|
+
let slotChildCounter = 0
|
|
121
127
|
const elementConfig0 = {}
|
|
122
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
128
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
123
129
|
elms[0].populate(elementConfig0)
|
|
130
|
+
if (inSlot === true) {
|
|
131
|
+
slotChildCounter -= 1
|
|
132
|
+
}
|
|
124
133
|
return elms
|
|
125
134
|
}
|
|
126
135
|
`
|
|
@@ -154,18 +163,27 @@ test('Generate code for a template with a simple element and a simple nested ele
|
|
|
154
163
|
}
|
|
155
164
|
|
|
156
165
|
const expectedRender = `
|
|
157
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
166
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
158
167
|
const elms = []
|
|
159
168
|
let componentType
|
|
160
169
|
const rootComponent = component
|
|
161
170
|
let propData
|
|
171
|
+
let slotComponent
|
|
172
|
+
let inSlot = false
|
|
173
|
+
let slotChildCounter = 0
|
|
162
174
|
const elementConfig0 = {}
|
|
163
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
175
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
164
176
|
elms[0].populate(elementConfig0)
|
|
177
|
+
if (inSlot === true) {
|
|
178
|
+
slotChildCounter -= 1
|
|
179
|
+
}
|
|
165
180
|
parent = elms[0]
|
|
166
181
|
const elementConfig1 = {}
|
|
167
|
-
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
182
|
+
elms[1] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
168
183
|
elms[1].populate(elementConfig1)
|
|
184
|
+
if (inSlot === true) {
|
|
185
|
+
slotChildCounter -= 1
|
|
186
|
+
}
|
|
169
187
|
return elms
|
|
170
188
|
}
|
|
171
189
|
`
|
|
@@ -196,17 +214,23 @@ test('Generate code for a template with a single element with attributes', (asse
|
|
|
196
214
|
}
|
|
197
215
|
|
|
198
216
|
const expectedRender = `
|
|
199
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
217
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
200
218
|
const elms = []
|
|
201
219
|
let componentType
|
|
202
220
|
const rootComponent = component
|
|
203
221
|
let propData
|
|
222
|
+
let slotComponent
|
|
223
|
+
let inSlot = false
|
|
224
|
+
let slotChildCounter = 0
|
|
204
225
|
const elementConfig0 = {}
|
|
205
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
226
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
206
227
|
|
|
207
228
|
elementConfig0['x'] = 10
|
|
208
229
|
elementConfig0['y'] = 20
|
|
209
230
|
elms[0].populate(elementConfig0)
|
|
231
|
+
if (inSlot === true) {
|
|
232
|
+
slotChildCounter -= 1
|
|
233
|
+
}
|
|
210
234
|
return elms
|
|
211
235
|
}
|
|
212
236
|
`
|
|
@@ -237,16 +261,23 @@ test('Generate code for a template with a single element with attributes with a
|
|
|
237
261
|
}
|
|
238
262
|
|
|
239
263
|
const expectedRender = `
|
|
240
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
264
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
241
265
|
const elms = []
|
|
242
266
|
let componentType
|
|
243
267
|
const rootComponent = component
|
|
244
268
|
let propData
|
|
269
|
+
let slotComponent
|
|
270
|
+
let inSlot = false
|
|
271
|
+
let slotChildCounter = 0
|
|
245
272
|
const elementConfig0 = {}
|
|
246
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
273
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
247
274
|
elementConfig0['one'] = true
|
|
248
275
|
elementConfig0['two'] = false
|
|
249
276
|
elms[0].populate(elementConfig0)
|
|
277
|
+
|
|
278
|
+
if (inSlot === true) {
|
|
279
|
+
slotChildCounter -= 1
|
|
280
|
+
}
|
|
250
281
|
return elms
|
|
251
282
|
}
|
|
252
283
|
`
|
|
@@ -284,27 +315,37 @@ test('Generate code for a template with attributes and a nested element with att
|
|
|
284
315
|
}
|
|
285
316
|
|
|
286
317
|
const expectedRender = `
|
|
287
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
318
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
288
319
|
const elms = []
|
|
289
320
|
let componentType
|
|
290
321
|
const rootComponent = component
|
|
291
322
|
let propData
|
|
323
|
+
let slotComponent
|
|
324
|
+
let inSlot = false
|
|
325
|
+
let slotChildCounter = 0
|
|
292
326
|
const elementConfig0 = {}
|
|
293
327
|
|
|
294
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
328
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
295
329
|
elementConfig0['x'] = 10
|
|
296
330
|
elementConfig0['y'] = 20
|
|
297
331
|
elms[0].populate(elementConfig0)
|
|
298
332
|
|
|
299
|
-
|
|
333
|
+
if (inSlot === true) {
|
|
334
|
+
slotChildCounter -= 1
|
|
335
|
+
}
|
|
300
336
|
|
|
337
|
+
parent = elms[0]
|
|
301
338
|
const elementConfig1 = {}
|
|
302
339
|
|
|
303
|
-
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
340
|
+
elms[1] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
304
341
|
elementConfig1['w'] = 100
|
|
305
342
|
elementConfig1['h'] = 300
|
|
306
343
|
elms[1].populate(elementConfig1)
|
|
307
344
|
|
|
345
|
+
if (inSlot === true) {
|
|
346
|
+
slotChildCounter -= 1
|
|
347
|
+
}
|
|
348
|
+
|
|
308
349
|
return elms
|
|
309
350
|
}
|
|
310
351
|
`
|
|
@@ -349,38 +390,51 @@ test('Generate code for a template with attributes and 2 nested elements with at
|
|
|
349
390
|
}
|
|
350
391
|
|
|
351
392
|
const expectedRender = `
|
|
352
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
393
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
353
394
|
const elms = []
|
|
354
395
|
let componentType
|
|
355
396
|
const rootComponent = component
|
|
356
397
|
let propData
|
|
398
|
+
let slotComponent
|
|
399
|
+
let inSlot = false
|
|
400
|
+
let slotChildCounter = 0
|
|
357
401
|
const elementConfig0 = {}
|
|
358
402
|
|
|
359
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
403
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
360
404
|
elementConfig0['x'] = 10
|
|
361
405
|
elementConfig0['y'] = 20
|
|
362
406
|
elms[0].populate(elementConfig0)
|
|
363
407
|
|
|
364
|
-
|
|
408
|
+
if (inSlot === true) {
|
|
409
|
+
slotChildCounter -= 1
|
|
410
|
+
}
|
|
365
411
|
|
|
412
|
+
parent = elms[0]
|
|
366
413
|
const elementConfig1 = {}
|
|
367
414
|
|
|
368
|
-
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
415
|
+
elms[1] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
369
416
|
elementConfig1['w'] = 100
|
|
370
417
|
elementConfig1['h'] = 300
|
|
371
418
|
elementConfig1['x'] = 0
|
|
372
419
|
elms[1].populate(elementConfig1)
|
|
373
420
|
|
|
374
|
-
|
|
421
|
+
if (inSlot === true) {
|
|
422
|
+
slotChildCounter -= 1
|
|
423
|
+
}
|
|
375
424
|
|
|
425
|
+
parent = elms[0]
|
|
376
426
|
const elementConfig2 = {}
|
|
377
427
|
|
|
378
|
-
elms[2] = this.element({ parent: parent || 'root' }, component)
|
|
428
|
+
elms[2] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
379
429
|
elementConfig2['w'] = 100
|
|
380
430
|
elementConfig2['h'] = 300
|
|
381
431
|
elementConfig2['x'] = 50
|
|
382
432
|
elms[2].populate(elementConfig2)
|
|
383
433
|
|
|
434
|
+
if (inSlot === true) {
|
|
435
|
+
slotChildCounter -= 1
|
|
436
|
+
}
|
|
437
|
+
|
|
384
438
|
return elms
|
|
385
439
|
}
|
|
386
440
|
`
|
|
@@ -435,54 +489,72 @@ test('Generate code for a template with attributes and deep nested elements with
|
|
|
435
489
|
}
|
|
436
490
|
|
|
437
491
|
const expectedRender = `
|
|
438
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
492
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
439
493
|
const elms = []
|
|
440
494
|
let componentType
|
|
441
495
|
const rootComponent = component
|
|
442
496
|
let propData
|
|
497
|
+
let slotComponent
|
|
498
|
+
let inSlot = false
|
|
499
|
+
let slotChildCounter = 0
|
|
443
500
|
const elementConfig0 = {}
|
|
444
501
|
|
|
445
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
502
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
446
503
|
elementConfig0['x'] = 10
|
|
447
504
|
elementConfig0['y'] = 20
|
|
448
505
|
elms[0].populate(elementConfig0)
|
|
449
506
|
|
|
450
|
-
|
|
507
|
+
if (inSlot === true) {
|
|
508
|
+
slotChildCounter -= 1
|
|
509
|
+
}
|
|
451
510
|
|
|
511
|
+
parent = elms[0]
|
|
452
512
|
const elementConfig1 = {}
|
|
453
513
|
|
|
454
|
-
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
514
|
+
elms[1] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
455
515
|
elementConfig1['w'] = 100
|
|
456
516
|
elementConfig1['h'] = 300
|
|
457
517
|
elementConfig1['x'] = 0
|
|
458
518
|
elms[1].populate(elementConfig1)
|
|
459
519
|
|
|
460
|
-
|
|
520
|
+
if (inSlot === true) {
|
|
521
|
+
slotChildCounter -= 1
|
|
522
|
+
}
|
|
461
523
|
|
|
524
|
+
parent = elms[0]
|
|
462
525
|
const elementConfig2 = {}
|
|
463
526
|
|
|
464
|
-
elms[2] = this.element({ parent: parent || 'root' }, component)
|
|
527
|
+
elms[2] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
465
528
|
elementConfig2['w'] = 100
|
|
466
529
|
elementConfig2['h'] = 300
|
|
467
530
|
elementConfig2['x'] = 50
|
|
468
531
|
elms[2].populate(elementConfig2)
|
|
469
532
|
|
|
470
|
-
|
|
533
|
+
if (inSlot === true) {
|
|
534
|
+
slotChildCounter -= 1
|
|
535
|
+
}
|
|
471
536
|
|
|
537
|
+
parent = elms[2]
|
|
472
538
|
const elementConfig3 = {}
|
|
473
539
|
|
|
474
|
-
elms[3] = this.element({ parent: parent || 'root' }, component)
|
|
540
|
+
elms[3] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
475
541
|
elementConfig3['label'] = "Hello"
|
|
476
542
|
elms[3].populate(elementConfig3)
|
|
477
543
|
|
|
478
|
-
|
|
544
|
+
if (inSlot === true) {
|
|
545
|
+
slotChildCounter -= 1
|
|
546
|
+
}
|
|
479
547
|
|
|
548
|
+
parent = elms[2]
|
|
480
549
|
const elementConfig4 = {}
|
|
481
550
|
|
|
482
|
-
elms[4] = this.element({ parent: parent || 'root' }, component)
|
|
551
|
+
elms[4] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
483
552
|
elementConfig4['label'] = "World"
|
|
484
553
|
elms[4].populate(elementConfig4)
|
|
485
554
|
|
|
555
|
+
if (inSlot === true) {
|
|
556
|
+
slotChildCounter -= 1
|
|
557
|
+
}
|
|
486
558
|
return elms
|
|
487
559
|
}
|
|
488
560
|
`
|
|
@@ -516,21 +588,30 @@ test('Generate code for a template with simple dynamic attributes', (assert) =>
|
|
|
516
588
|
}
|
|
517
589
|
|
|
518
590
|
const expectedRender = `
|
|
519
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
591
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
520
592
|
const elms = []
|
|
521
593
|
let componentType
|
|
522
594
|
const rootComponent = component
|
|
523
595
|
let propData
|
|
596
|
+
let slotComponent
|
|
597
|
+
let inSlot = false
|
|
598
|
+
let slotChildCounter = 0
|
|
524
599
|
const elementConfig0 = {}
|
|
525
600
|
|
|
526
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
601
|
+
elms[0] = this.element( { parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
602
|
+
|
|
527
603
|
elementConfig0['x'] = 10
|
|
528
604
|
elementConfig0['y'] = 20
|
|
529
605
|
elementConfig0['w'] = component.foo
|
|
530
606
|
elementConfig0['h'] = component.test
|
|
531
607
|
elementConfig0['test'] = "ok"
|
|
608
|
+
|
|
532
609
|
elms[0].populate(elementConfig0)
|
|
533
610
|
|
|
611
|
+
if (inSlot === true) {
|
|
612
|
+
slotChildCounter -= 1
|
|
613
|
+
}
|
|
614
|
+
|
|
534
615
|
return elms
|
|
535
616
|
}
|
|
536
617
|
`
|
|
@@ -585,18 +666,24 @@ test('Generate code for a template with an attribute with a dash', (assert) => {
|
|
|
585
666
|
}
|
|
586
667
|
|
|
587
668
|
const expectedRender = `
|
|
588
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
669
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
589
670
|
const elms = []
|
|
590
671
|
let componentType
|
|
591
672
|
const rootComponent = component
|
|
592
673
|
let propData
|
|
674
|
+
let slotComponent
|
|
675
|
+
let inSlot = false
|
|
676
|
+
let slotChildCounter = 0
|
|
593
677
|
const elementConfig0 = {}
|
|
594
678
|
|
|
595
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
679
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
596
680
|
elementConfig0['my-Attribute'] = "doesitwork?"
|
|
597
681
|
elementConfig0['x'] = 10
|
|
598
682
|
elementConfig0['y'] = 20
|
|
599
683
|
elms[0].populate(elementConfig0)
|
|
684
|
+
if (inSlot === true) {
|
|
685
|
+
slotChildCounter -= 1
|
|
686
|
+
}
|
|
600
687
|
|
|
601
688
|
return elms
|
|
602
689
|
}
|
|
@@ -630,18 +717,24 @@ test('Generate code for a template with dynamic attributes with code to be evalu
|
|
|
630
717
|
}
|
|
631
718
|
|
|
632
719
|
const expectedRender = `
|
|
633
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
720
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
634
721
|
const elms = []
|
|
635
722
|
let componentType
|
|
636
723
|
const rootComponent = component
|
|
637
724
|
let propData
|
|
725
|
+
let slotComponent
|
|
726
|
+
let inSlot = false
|
|
727
|
+
let slotChildCounter = 0
|
|
638
728
|
const elementConfig0 = {}
|
|
639
729
|
|
|
640
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
730
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
641
731
|
elementConfig0['attribute1'] = component.foo * 2
|
|
642
732
|
elementConfig0['attribute2'] = component.ok ? 'Yes' : 'No'
|
|
643
733
|
elementConfig0['attribute3'] = component.text.split('').reverse().join('')
|
|
644
734
|
elms[0].populate(elementConfig0)
|
|
735
|
+
if (inSlot === true) {
|
|
736
|
+
slotChildCounter -= 1
|
|
737
|
+
}
|
|
645
738
|
|
|
646
739
|
return elms
|
|
647
740
|
}
|
|
@@ -708,18 +801,24 @@ test('Generate code for a template with attribute (object)', (assert) => {
|
|
|
708
801
|
}
|
|
709
802
|
|
|
710
803
|
const expectedRender = `
|
|
711
|
-
function anonymous(parent,component,context,components,effect,getRaw) {
|
|
804
|
+
function anonymous(parent,component,context,components,effect,getRaw,Log) {
|
|
712
805
|
const elms = []
|
|
713
806
|
let componentType
|
|
714
807
|
const rootComponent = component
|
|
715
808
|
let propData
|
|
809
|
+
let slotComponent
|
|
810
|
+
let inSlot = false
|
|
811
|
+
let slotChildCounter = 0
|
|
716
812
|
const elementConfig0 = {}
|
|
717
813
|
|
|
718
|
-
elms[0] = this.element({parent: parent || 'root'}, component)
|
|
814
|
+
elms[0] = this.element({parent: parent || 'root'}, inSlot === true ? slotComponent : component)
|
|
719
815
|
elementConfig0['w'] = 100
|
|
720
816
|
elementConfig0['h'] = 100
|
|
721
817
|
elementConfig0['color'] = "{top: 0xff0000ff, bottom: 0x008000ff, left: 0xffff00ff}"
|
|
722
818
|
elms[0].populate(elementConfig0)
|
|
819
|
+
if (inSlot === true) {
|
|
820
|
+
slotChildCounter -= 1
|
|
821
|
+
}
|
|
723
822
|
|
|
724
823
|
return elms
|
|
725
824
|
}
|
|
@@ -752,18 +851,24 @@ test('Generate code for a template with dynamic attribute (object)', (assert) =>
|
|
|
752
851
|
}
|
|
753
852
|
|
|
754
853
|
const expectedRender = `
|
|
755
|
-
function anonymous(parent,component,context,components,effect,getRaw) {
|
|
854
|
+
function anonymous(parent,component,context,components,effect,getRaw,Log) {
|
|
756
855
|
const elms = []
|
|
757
856
|
let componentType
|
|
758
857
|
const rootComponent = component
|
|
759
858
|
let propData
|
|
859
|
+
let slotComponent
|
|
860
|
+
let inSlot = false
|
|
861
|
+
let slotChildCounter = 0
|
|
760
862
|
const elementConfig0 = {}
|
|
761
863
|
|
|
762
|
-
elms[0] = this.element({parent: parent || 'root'}, component)
|
|
864
|
+
elms[0] = this.element({parent: parent || 'root'}, inSlot === true ? slotComponent : component)
|
|
763
865
|
elementConfig0['w'] = 100
|
|
764
866
|
elementConfig0['h'] = 100
|
|
765
867
|
elementConfig0['color'] = { top: component.colorT, bottom: component.colorB, left: component.colorL }
|
|
766
868
|
elms[0].populate(elementConfig0)
|
|
869
|
+
if (inSlot === true) {
|
|
870
|
+
slotChildCounter -= 1
|
|
871
|
+
}
|
|
767
872
|
|
|
768
873
|
return elms
|
|
769
874
|
}
|
|
@@ -797,18 +902,24 @@ test('Generate code for a template with attribute (object) with mixed dynamic &
|
|
|
797
902
|
}
|
|
798
903
|
|
|
799
904
|
const expectedRender = `
|
|
800
|
-
function anonymous(parent,component,context,components,effect,getRaw) {
|
|
905
|
+
function anonymous(parent,component,context,components,effect,getRaw,Log) {
|
|
801
906
|
const elms = []
|
|
802
907
|
let componentType
|
|
803
908
|
const rootComponent = component
|
|
804
909
|
let propData
|
|
910
|
+
let slotComponent
|
|
911
|
+
let inSlot = false
|
|
912
|
+
let slotChildCounter = 0
|
|
805
913
|
const elementConfig0 = {}
|
|
806
914
|
|
|
807
|
-
elms[0] = this.element({parent: parent || 'root'}, component)
|
|
915
|
+
elms[0] = this.element({parent: parent || 'root'}, inSlot === true ? slotComponent : component)
|
|
808
916
|
elementConfig0['w'] = 100
|
|
809
917
|
elementConfig0['h'] = 100
|
|
810
918
|
elementConfig0['color'] = { top: 0xff0000ff, bottom: component.colorB, left: component.colorL }
|
|
811
919
|
elms[0].populate(elementConfig0)
|
|
920
|
+
if (inSlot === true) {
|
|
921
|
+
slotChildCounter -= 1
|
|
922
|
+
}
|
|
812
923
|
|
|
813
924
|
return elms
|
|
814
925
|
}
|
|
@@ -842,18 +953,24 @@ test('Generate code for a template with @-listeners', (assert) => {
|
|
|
842
953
|
}
|
|
843
954
|
|
|
844
955
|
const expectedRender = `
|
|
845
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
956
|
+
function anonymous(parent, component, context, components, effect, getRaw,Log) {
|
|
846
957
|
const elms = []
|
|
847
958
|
let componentType
|
|
848
959
|
const rootComponent = component
|
|
849
960
|
let propData
|
|
961
|
+
let slotComponent
|
|
962
|
+
let inSlot = false
|
|
963
|
+
let slotChildCounter = 0
|
|
850
964
|
const elementConfig0 = {}
|
|
851
965
|
|
|
852
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
966
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
853
967
|
elementConfig0['src'] = "myImage.png"
|
|
854
968
|
elementConfig0['@loaded'] = component['loadedCallback'] && component['loadedCallback'].bind(component)
|
|
855
969
|
elementConfig0['@error'] = component['errorCallback'] && component['errorCallback'].bind(component)
|
|
856
970
|
elms[0].populate(elementConfig0)
|
|
971
|
+
if (inSlot === true) {
|
|
972
|
+
slotChildCounter -= 1
|
|
973
|
+
}
|
|
857
974
|
|
|
858
975
|
return elms
|
|
859
976
|
}
|
|
@@ -897,21 +1014,27 @@ test('Generate code for a template with custom components', (assert) => {
|
|
|
897
1014
|
}
|
|
898
1015
|
|
|
899
1016
|
const expectedRender = `
|
|
900
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
1017
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
901
1018
|
const elms = []
|
|
902
1019
|
let componentType
|
|
903
1020
|
const rootComponent = component
|
|
904
1021
|
let propData
|
|
1022
|
+
let slotComponent
|
|
1023
|
+
let inSlot = false
|
|
1024
|
+
let slotChildCounter = 0
|
|
905
1025
|
const elementConfig0 = {}
|
|
906
1026
|
|
|
907
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
1027
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
908
1028
|
elms[0].populate(elementConfig0)
|
|
1029
|
+
if (inSlot === true) {
|
|
1030
|
+
slotChildCounter -= 1
|
|
1031
|
+
}
|
|
909
1032
|
|
|
910
1033
|
const cmp1 = (context.components && context.components['Poster']) || components['Poster']
|
|
911
1034
|
parent = elms[0]
|
|
912
1035
|
const elementConfig1 = {}
|
|
913
1036
|
|
|
914
|
-
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
1037
|
+
elms[1] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
915
1038
|
const skip1 = []
|
|
916
1039
|
|
|
917
1040
|
if (typeof cmp1 !== 'undefined') {
|
|
@@ -922,8 +1045,11 @@ test('Generate code for a template with custom components', (assert) => {
|
|
|
922
1045
|
}
|
|
923
1046
|
|
|
924
1047
|
elms[1].populate(elementConfig1)
|
|
925
|
-
parent = elms[1]
|
|
926
1048
|
|
|
1049
|
+
if (inSlot === true) {
|
|
1050
|
+
slotChildCounter -= 1
|
|
1051
|
+
}
|
|
1052
|
+
parent = elms[1]
|
|
927
1053
|
const props2 = {}
|
|
928
1054
|
componentType = props2['is'] || 'Poster'
|
|
929
1055
|
let component2
|
|
@@ -941,16 +1067,20 @@ test('Generate code for a template with custom components', (assert) => {
|
|
|
941
1067
|
|
|
942
1068
|
if (elms[2][Symbol.for('slots')][0]) {
|
|
943
1069
|
parent = elms[2][Symbol.for('slots')][0]
|
|
944
|
-
|
|
1070
|
+
slotComponent = elms[2]
|
|
1071
|
+
inSlot = true
|
|
945
1072
|
} else {
|
|
946
1073
|
parent = elms[2][Symbol.for('children')][0]
|
|
947
1074
|
}
|
|
1075
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1076
|
+
inSlot = false
|
|
1077
|
+
}
|
|
948
1078
|
|
|
949
1079
|
const cmp3 = (context.components && context.components['Poster']) || components['Poster']
|
|
950
1080
|
parent = elms[0]
|
|
951
1081
|
const elementConfig3 = {}
|
|
952
1082
|
|
|
953
|
-
elms[3] = this.element({ parent: parent || 'root' }, component)
|
|
1083
|
+
elms[3] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
954
1084
|
const skip3 = []
|
|
955
1085
|
|
|
956
1086
|
if (typeof cmp3 !== 'undefined') {
|
|
@@ -961,8 +1091,11 @@ test('Generate code for a template with custom components', (assert) => {
|
|
|
961
1091
|
}
|
|
962
1092
|
|
|
963
1093
|
elms[3].populate(elementConfig3)
|
|
964
|
-
|
|
1094
|
+
if (inSlot === true) {
|
|
1095
|
+
slotChildCounter -= 1
|
|
1096
|
+
}
|
|
965
1097
|
|
|
1098
|
+
parent = elms[3]
|
|
966
1099
|
const props4 = {}
|
|
967
1100
|
componentType = props4['is'] || 'Poster'
|
|
968
1101
|
let component4
|
|
@@ -980,14 +1113,18 @@ test('Generate code for a template with custom components', (assert) => {
|
|
|
980
1113
|
|
|
981
1114
|
if (elms[4][Symbol.for('slots')][0]) {
|
|
982
1115
|
parent = elms[4][Symbol.for('slots')][0]
|
|
983
|
-
|
|
1116
|
+
slotComponent = elms[4]
|
|
1117
|
+
inSlot = true
|
|
984
1118
|
} else {
|
|
985
1119
|
parent = elms[4][Symbol.for('children')][0]
|
|
986
1120
|
}
|
|
987
1121
|
|
|
1122
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1123
|
+
inSlot = false
|
|
1124
|
+
}
|
|
1125
|
+
|
|
988
1126
|
return elms
|
|
989
1127
|
}
|
|
990
|
-
|
|
991
1128
|
`
|
|
992
1129
|
|
|
993
1130
|
const actual = generator.call(scope, templateObject)
|
|
@@ -1029,18 +1166,25 @@ test('Generate code for a template with an unregistered custom component', (asse
|
|
|
1029
1166
|
}
|
|
1030
1167
|
|
|
1031
1168
|
const expectedRender = `
|
|
1032
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
1169
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
1033
1170
|
const elms = []
|
|
1034
1171
|
let componentType
|
|
1035
1172
|
const rootComponent = component
|
|
1036
1173
|
let propData
|
|
1174
|
+
let slotComponent
|
|
1175
|
+
let inSlot = false
|
|
1176
|
+
let slotChildCounter = 0
|
|
1037
1177
|
const elementConfig0 = {}
|
|
1038
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
1178
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1039
1179
|
elms[0].populate(elementConfig0)
|
|
1180
|
+
if (inSlot === true) {
|
|
1181
|
+
slotChildCounter -= 1
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1040
1184
|
const cmp1 = (context.components && context.components['Poster']) || components['Poster']
|
|
1041
1185
|
parent = elms[0]
|
|
1042
1186
|
const elementConfig1 = {}
|
|
1043
|
-
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
1187
|
+
elms[1] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1044
1188
|
const skip1 = []
|
|
1045
1189
|
if (typeof cmp1 !== 'undefined') {
|
|
1046
1190
|
for (let key in cmp1.config.props) {
|
|
@@ -1049,6 +1193,9 @@ test('Generate code for a template with an unregistered custom component', (asse
|
|
|
1049
1193
|
}
|
|
1050
1194
|
}
|
|
1051
1195
|
elms[1].populate(elementConfig1)
|
|
1196
|
+
if (inSlot === true) {
|
|
1197
|
+
slotChildCounter -= 1
|
|
1198
|
+
}
|
|
1052
1199
|
parent = elms[1]
|
|
1053
1200
|
const props2 = {}
|
|
1054
1201
|
componentType = props2['is'] || 'Poster'
|
|
@@ -1064,14 +1211,20 @@ test('Generate code for a template with an unregistered custom component', (asse
|
|
|
1064
1211
|
elms[2] = component2.call(null, { props: props2 }, elms[1], component)
|
|
1065
1212
|
if (elms[2][Symbol.for('slots')][0]) {
|
|
1066
1213
|
parent = elms[2][Symbol.for('slots')][0]
|
|
1067
|
-
|
|
1214
|
+
slotComponent = elms[2]
|
|
1215
|
+
inSlot = true
|
|
1068
1216
|
} else {
|
|
1069
1217
|
parent = elms[2][Symbol.for('children')][0]
|
|
1070
1218
|
}
|
|
1219
|
+
|
|
1220
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1221
|
+
inSlot = false
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1071
1224
|
const cmp3 = (context.components && context.components['Poster2']) || components['Poster2']
|
|
1072
1225
|
parent = elms[0]
|
|
1073
1226
|
const elementConfig3 = {}
|
|
1074
|
-
elms[3] = this.element({ parent: parent || 'root' }, component)
|
|
1227
|
+
elms[3] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1075
1228
|
const skip3 = []
|
|
1076
1229
|
if (typeof cmp3 !== 'undefined') {
|
|
1077
1230
|
for (let key in cmp3.config.props) {
|
|
@@ -1080,6 +1233,9 @@ test('Generate code for a template with an unregistered custom component', (asse
|
|
|
1080
1233
|
}
|
|
1081
1234
|
}
|
|
1082
1235
|
elms[3].populate(elementConfig3)
|
|
1236
|
+
if (inSlot === true) {
|
|
1237
|
+
slotChildCounter -= 1
|
|
1238
|
+
}
|
|
1083
1239
|
parent = elms[3]
|
|
1084
1240
|
const props4 = {}
|
|
1085
1241
|
componentType = props4['is'] || 'Poster2'
|
|
@@ -1095,10 +1251,16 @@ test('Generate code for a template with an unregistered custom component', (asse
|
|
|
1095
1251
|
elms[4] = component4.call(null, { props: props4 }, elms[3], component)
|
|
1096
1252
|
if (elms[4][Symbol.for('slots')][0]) {
|
|
1097
1253
|
parent = elms[4][Symbol.for('slots')][0]
|
|
1098
|
-
|
|
1254
|
+
slotComponent = elms[4]
|
|
1255
|
+
inSlot = true
|
|
1099
1256
|
} else {
|
|
1100
1257
|
parent = elms[4][Symbol.for('children')][0]
|
|
1101
1258
|
}
|
|
1259
|
+
|
|
1260
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1261
|
+
inSlot = false
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1102
1264
|
return elms
|
|
1103
1265
|
}
|
|
1104
1266
|
`
|
|
@@ -1145,18 +1307,25 @@ test('Generate code for a template with custom components with arguments', (asse
|
|
|
1145
1307
|
}
|
|
1146
1308
|
|
|
1147
1309
|
const expectedRender = `
|
|
1148
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
1310
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
1149
1311
|
const elms = []
|
|
1150
1312
|
let componentType
|
|
1151
1313
|
const rootComponent = component
|
|
1152
1314
|
let propData
|
|
1315
|
+
let slotComponent
|
|
1316
|
+
let inSlot = false
|
|
1317
|
+
let slotChildCounter = 0
|
|
1153
1318
|
const elementConfig0 = {}
|
|
1154
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
1319
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1155
1320
|
elms[0].populate(elementConfig0)
|
|
1321
|
+
if (inSlot === true) {
|
|
1322
|
+
slotChildCounter -= 1
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1156
1325
|
const cmp1 = (context.components && context.components['Poster']) || components['Poster']
|
|
1157
1326
|
parent = elms[0]
|
|
1158
1327
|
const elementConfig1 = {}
|
|
1159
|
-
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
1328
|
+
elms[1] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1160
1329
|
elementConfig1['x'] = 10
|
|
1161
1330
|
const skip1 = []
|
|
1162
1331
|
if (typeof cmp1 !== 'undefined') {
|
|
@@ -1166,6 +1335,10 @@ test('Generate code for a template with custom components with arguments', (asse
|
|
|
1166
1335
|
}
|
|
1167
1336
|
}
|
|
1168
1337
|
elms[1].populate(elementConfig1)
|
|
1338
|
+
if (inSlot === true) {
|
|
1339
|
+
slotChildCounter -= 1
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1169
1342
|
parent = elms[1]
|
|
1170
1343
|
const props2 = {}
|
|
1171
1344
|
props2['x'] = 10
|
|
@@ -1182,14 +1355,19 @@ test('Generate code for a template with custom components with arguments', (asse
|
|
|
1182
1355
|
elms[2] = component2.call(null, { props: props2 }, elms[1], component)
|
|
1183
1356
|
if (elms[2][Symbol.for('slots')][0]) {
|
|
1184
1357
|
parent = elms[2][Symbol.for('slots')][0]
|
|
1185
|
-
|
|
1358
|
+
slotComponent = elms[2]
|
|
1359
|
+
inSlot = true
|
|
1186
1360
|
} else {
|
|
1187
1361
|
parent = elms[2][Symbol.for('children')][0]
|
|
1188
1362
|
}
|
|
1363
|
+
|
|
1364
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1365
|
+
inSlot = false
|
|
1366
|
+
}
|
|
1189
1367
|
const cmp3 = (context.components && context.components['Poster']) || components['Poster']
|
|
1190
1368
|
parent = elms[0]
|
|
1191
1369
|
const elementConfig3 = {}
|
|
1192
|
-
elms[3] = this.element({ parent: parent || 'root' }, component)
|
|
1370
|
+
elms[3] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1193
1371
|
elementConfig3['x'] = 100
|
|
1194
1372
|
elementConfig3['img'] = component.img
|
|
1195
1373
|
const skip3 = []
|
|
@@ -1200,6 +1378,9 @@ test('Generate code for a template with custom components with arguments', (asse
|
|
|
1200
1378
|
}
|
|
1201
1379
|
}
|
|
1202
1380
|
elms[3].populate(elementConfig3)
|
|
1381
|
+
if (inSlot === true) {
|
|
1382
|
+
slotChildCounter -= 1
|
|
1383
|
+
}
|
|
1203
1384
|
parent = elms[3]
|
|
1204
1385
|
const props4 = {}
|
|
1205
1386
|
props4['x'] = 100
|
|
@@ -1217,10 +1398,16 @@ test('Generate code for a template with custom components with arguments', (asse
|
|
|
1217
1398
|
elms[4] = component4.call(null, { props: props4 }, elms[3], component)
|
|
1218
1399
|
if (elms[4][Symbol.for('slots')][0]) {
|
|
1219
1400
|
parent = elms[4][Symbol.for('slots')][0]
|
|
1220
|
-
|
|
1401
|
+
slotComponent = elms[4]
|
|
1402
|
+
inSlot = true
|
|
1221
1403
|
} else {
|
|
1222
1404
|
parent = elms[4][Symbol.for('children')][0]
|
|
1223
1405
|
}
|
|
1406
|
+
|
|
1407
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1408
|
+
inSlot = false
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1224
1411
|
return elms
|
|
1225
1412
|
}
|
|
1226
1413
|
`
|
|
@@ -1268,18 +1455,25 @@ test('Generate code for a template with custom components with reactive props',
|
|
|
1268
1455
|
}
|
|
1269
1456
|
|
|
1270
1457
|
const expectedRender = `
|
|
1271
|
-
function anonymous(parent,component,context,components,effect,getRaw) {
|
|
1458
|
+
function anonymous(parent,component,context,components,effect,getRaw,Log) {
|
|
1272
1459
|
const elms = []
|
|
1273
1460
|
let componentType
|
|
1274
1461
|
const rootComponent = component
|
|
1275
1462
|
let propData
|
|
1463
|
+
let slotComponent
|
|
1464
|
+
let inSlot = false
|
|
1465
|
+
let slotChildCounter = 0
|
|
1276
1466
|
const elementConfig0 = {}
|
|
1277
|
-
elms[0] = this.element({parent: parent || 'root'}, component)
|
|
1467
|
+
elms[0] = this.element({parent: parent || 'root'}, inSlot === true ? slotComponent : component)
|
|
1278
1468
|
elms[0].populate(elementConfig0)
|
|
1469
|
+
if (inSlot === true) {
|
|
1470
|
+
slotChildCounter -= 1
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1279
1473
|
const cmp1 = (context.components && context.components['Poster']) || components['Poster']
|
|
1280
1474
|
parent = elms[0]
|
|
1281
1475
|
const elementConfig1 = {}
|
|
1282
|
-
elms[1] = this.element({parent: parent || 'root'}, component)
|
|
1476
|
+
elms[1] = this.element({parent: parent || 'root'}, inSlot === true ? slotComponent : component)
|
|
1283
1477
|
elementConfig1['x'] = 10
|
|
1284
1478
|
elementConfig1['img'] = component.image
|
|
1285
1479
|
const skip1 = []
|
|
@@ -1290,6 +1484,10 @@ test('Generate code for a template with custom components with reactive props',
|
|
|
1290
1484
|
}
|
|
1291
1485
|
}
|
|
1292
1486
|
elms[1].populate(elementConfig1)
|
|
1487
|
+
if (inSlot === true) {
|
|
1488
|
+
slotChildCounter -= 1
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1293
1491
|
parent = elms[1]
|
|
1294
1492
|
const props2 = {}
|
|
1295
1493
|
props2['x'] = 10
|
|
@@ -1311,14 +1509,20 @@ test('Generate code for a template with custom components with reactive props',
|
|
|
1311
1509
|
elms[2] = component2.call(null, {props: props2}, elms[1], component)
|
|
1312
1510
|
if (elms[2][Symbol.for('slots')][0]) {
|
|
1313
1511
|
parent = elms[2][Symbol.for('slots')][0]
|
|
1314
|
-
|
|
1512
|
+
slotComponent = elms[2]
|
|
1513
|
+
inSlot = true
|
|
1315
1514
|
} else {
|
|
1316
1515
|
parent = elms[2][Symbol.for('children')][0]
|
|
1317
1516
|
}
|
|
1517
|
+
|
|
1518
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1519
|
+
inSlot = false
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1318
1522
|
const cmp3 = (context.components && context.components['Poster']) || components['Poster']
|
|
1319
1523
|
parent = elms[0]
|
|
1320
1524
|
const elementConfig3 = {}
|
|
1321
|
-
elms[3] = this.element({parent: parent || 'root'}, component)
|
|
1525
|
+
elms[3] = this.element({parent: parent || 'root'}, inSlot === true ? slotComponent : component)
|
|
1322
1526
|
elementConfig3['x'] = 100
|
|
1323
1527
|
elementConfig3['img'] = component.image
|
|
1324
1528
|
const skip3 = []
|
|
@@ -1329,6 +1533,10 @@ test('Generate code for a template with custom components with reactive props',
|
|
|
1329
1533
|
}
|
|
1330
1534
|
}
|
|
1331
1535
|
elms[3].populate(elementConfig3)
|
|
1536
|
+
if (inSlot === true) {
|
|
1537
|
+
slotChildCounter -= 1
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1332
1540
|
parent = elms[3]
|
|
1333
1541
|
const props4 = {}
|
|
1334
1542
|
props4['x'] = 100
|
|
@@ -1350,10 +1558,16 @@ test('Generate code for a template with custom components with reactive props',
|
|
|
1350
1558
|
elms[4] = component4.call(null, {props: props4}, elms[3], component)
|
|
1351
1559
|
if (elms[4][Symbol.for('slots')][0]) {
|
|
1352
1560
|
parent = elms[4][Symbol.for('slots')][0]
|
|
1353
|
-
|
|
1561
|
+
slotComponent = elms[4]
|
|
1562
|
+
inSlot = true
|
|
1354
1563
|
} else {
|
|
1355
1564
|
parent = elms[4][Symbol.for('children')][0]
|
|
1356
1565
|
}
|
|
1566
|
+
|
|
1567
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1568
|
+
inSlot = false
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1357
1571
|
return elms
|
|
1358
1572
|
}
|
|
1359
1573
|
`
|
|
@@ -1436,17 +1650,25 @@ test('Generate code for a template with a transition attributes', (assert) => {
|
|
|
1436
1650
|
}
|
|
1437
1651
|
|
|
1438
1652
|
const expectedRender = `
|
|
1439
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
1653
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
1440
1654
|
const elms = []
|
|
1441
1655
|
let componentType
|
|
1442
1656
|
const rootComponent = component
|
|
1443
1657
|
let propData
|
|
1658
|
+
let slotComponent
|
|
1659
|
+
let inSlot = false
|
|
1660
|
+
let slotChildCounter = 0
|
|
1444
1661
|
const elementConfig0 = {}
|
|
1445
1662
|
|
|
1446
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
1663
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1447
1664
|
elementConfig0['x'] = {transition:component.myX}
|
|
1448
1665
|
elementConfig0['y'] = {transition:{value:component.myY,duration:600}}
|
|
1449
1666
|
elms[0].populate(elementConfig0)
|
|
1667
|
+
|
|
1668
|
+
if (inSlot === true) {
|
|
1669
|
+
slotChildCounter -= 1
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1450
1672
|
return elms
|
|
1451
1673
|
}
|
|
1452
1674
|
`
|
|
@@ -1495,18 +1717,25 @@ test('Generate code for a template with slot content', (assert) => {
|
|
|
1495
1717
|
}
|
|
1496
1718
|
|
|
1497
1719
|
const expectedRender = `
|
|
1498
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
1720
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
1499
1721
|
const elms = []
|
|
1500
1722
|
let componentType
|
|
1501
1723
|
const rootComponent = component
|
|
1502
1724
|
let propData
|
|
1725
|
+
let slotComponent
|
|
1726
|
+
let inSlot = false
|
|
1727
|
+
let slotChildCounter = 0
|
|
1503
1728
|
const elementConfig0 = {}
|
|
1504
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
1729
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1505
1730
|
elms[0].populate(elementConfig0)
|
|
1731
|
+
if (inSlot === true) {
|
|
1732
|
+
slotChildCounter -= 1
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1506
1735
|
const cmp1 = (context.components && context.components['Page']) || components['Page']
|
|
1507
1736
|
parent = elms[0]
|
|
1508
1737
|
const elementConfig1 = {}
|
|
1509
|
-
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
1738
|
+
elms[1] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1510
1739
|
elementConfig1['w'] = 1920
|
|
1511
1740
|
elementConfig1['h'] = 1080
|
|
1512
1741
|
const skip1 = []
|
|
@@ -1517,6 +1746,10 @@ test('Generate code for a template with slot content', (assert) => {
|
|
|
1517
1746
|
}
|
|
1518
1747
|
}
|
|
1519
1748
|
elms[1].populate(elementConfig1)
|
|
1749
|
+
if (inSlot === true) {
|
|
1750
|
+
slotChildCounter -= 1
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1520
1753
|
parent = elms[1]
|
|
1521
1754
|
const props2 = {}
|
|
1522
1755
|
props2['w'] = 1920
|
|
@@ -1534,20 +1767,37 @@ test('Generate code for a template with slot content', (assert) => {
|
|
|
1534
1767
|
elms[2] = component2.call(null, { props: props2 }, elms[1], component)
|
|
1535
1768
|
if (elms[2][Symbol.for('slots')][0]) {
|
|
1536
1769
|
parent = elms[2][Symbol.for('slots')][0]
|
|
1537
|
-
|
|
1770
|
+
slotComponent = elms[2]
|
|
1771
|
+
inSlot = true
|
|
1538
1772
|
} else {
|
|
1539
1773
|
parent = elms[2][Symbol.for('children')][0]
|
|
1540
1774
|
}
|
|
1775
|
+
if (inSlot === true) {
|
|
1776
|
+
slotChildCounter = 1 + 1
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1541
1779
|
const elementConfig3 = {}
|
|
1542
|
-
elms[3] = this.element({ parent: parent || 'root' }, component)
|
|
1780
|
+
elms[3] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1543
1781
|
elms[3].populate(elementConfig3)
|
|
1782
|
+
if (inSlot === true) {
|
|
1783
|
+
slotChildCounter -= 1
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1544
1786
|
parent = elms[3]
|
|
1545
1787
|
const elementConfig4 = {}
|
|
1546
|
-
elms[4] = this.element({ parent: parent || 'root' }, component)
|
|
1788
|
+
elms[4] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1547
1789
|
elementConfig4['x'] = 100
|
|
1548
1790
|
elementConfig4['y'] = component.y
|
|
1549
1791
|
elementConfig4['rotation'] = component.rotate
|
|
1550
1792
|
elms[4].populate(elementConfig4)
|
|
1793
|
+
if (inSlot === true) {
|
|
1794
|
+
slotChildCounter -= 1
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1798
|
+
inSlot = false
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1551
1801
|
return elms
|
|
1552
1802
|
}
|
|
1553
1803
|
`
|
|
@@ -1611,18 +1861,25 @@ test('Generate code for a template with slot content, using a named slot', (asse
|
|
|
1611
1861
|
}
|
|
1612
1862
|
|
|
1613
1863
|
const expectedRender = `
|
|
1614
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
1864
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
1615
1865
|
const elms = []
|
|
1616
1866
|
let componentType
|
|
1617
1867
|
const rootComponent = component
|
|
1618
1868
|
let propData
|
|
1869
|
+
let slotComponent
|
|
1870
|
+
let inSlot = false
|
|
1871
|
+
let slotChildCounter = 0
|
|
1619
1872
|
const elementConfig0 = {}
|
|
1620
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
1873
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1621
1874
|
elms[0].populate(elementConfig0)
|
|
1875
|
+
if (inSlot === true) {
|
|
1876
|
+
slotChildCounter -= 1
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1622
1879
|
const cmp1 = (context.components && context.components['Page']) || components['Page']
|
|
1623
1880
|
parent = elms[0]
|
|
1624
1881
|
const elementConfig1 = {}
|
|
1625
|
-
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
1882
|
+
elms[1] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1626
1883
|
elementConfig1['w'] = 1920
|
|
1627
1884
|
elementConfig1['h'] = 1080
|
|
1628
1885
|
const skip1 = []
|
|
@@ -1633,6 +1890,10 @@ test('Generate code for a template with slot content, using a named slot', (asse
|
|
|
1633
1890
|
}
|
|
1634
1891
|
}
|
|
1635
1892
|
elms[1].populate(elementConfig1)
|
|
1893
|
+
if (inSlot === true) {
|
|
1894
|
+
slotChildCounter -= 1
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1636
1897
|
parent = elms[1]
|
|
1637
1898
|
const props2 = {}
|
|
1638
1899
|
props2['w'] = 1920
|
|
@@ -1650,21 +1911,42 @@ test('Generate code for a template with slot content, using a named slot', (asse
|
|
|
1650
1911
|
elms[2] = component2.call(null, { props: props2 }, elms[1], component)
|
|
1651
1912
|
if (elms[2][Symbol.for('slots')][0]) {
|
|
1652
1913
|
parent = elms[2][Symbol.for('slots')][0]
|
|
1653
|
-
|
|
1914
|
+
slotComponent = elms[2]
|
|
1915
|
+
inSlot = true
|
|
1654
1916
|
} else {
|
|
1655
1917
|
parent = elms[2][Symbol.for('children')][0]
|
|
1656
1918
|
}
|
|
1919
|
+
|
|
1920
|
+
if (inSlot === true) {
|
|
1921
|
+
slotChildCounter = 1 + 1
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1657
1924
|
const elementConfig3 = {}
|
|
1658
|
-
elms[3] = this.element({ parent: parent || 'root' }, component)
|
|
1925
|
+
elms[3] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1659
1926
|
elms[3].populate(elementConfig3)
|
|
1927
|
+
if (inSlot === true) {
|
|
1928
|
+
slotChildCounter -= 1
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1660
1931
|
parent = elms[3]
|
|
1661
1932
|
const elementConfig4 = {}
|
|
1662
|
-
elms[4] = this.element({ parent: parent || 'root' }, component)
|
|
1933
|
+
elms[4] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1663
1934
|
elementConfig4['x'] = 100
|
|
1664
1935
|
elementConfig4['y'] = component.y
|
|
1665
|
-
elementConfig4['parent'] = component[Symbol.for('slots')]
|
|
1936
|
+
elementConfig4['parent'] = component[Symbol.for('slots')] !== undefined &&
|
|
1937
|
+
Array.isArray(component[Symbol.for('slots')]) === true &&
|
|
1938
|
+
component[Symbol.for('slots')].filter(slot => slot.ref === 'mySlot').shift() || parent
|
|
1666
1939
|
elementConfig4['slot'] = "mySlot"
|
|
1667
1940
|
elms[4].populate(elementConfig4)
|
|
1941
|
+
|
|
1942
|
+
if (inSlot === true) {
|
|
1943
|
+
slotChildCounter -= 1
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
if (inSlot === true && slotChildCounter === 0) {
|
|
1947
|
+
inSlot = false
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1668
1950
|
return elms
|
|
1669
1951
|
}
|
|
1670
1952
|
`
|
|
@@ -1709,30 +1991,43 @@ test('Generate code for a template with a slot', (assert) => {
|
|
|
1709
1991
|
}
|
|
1710
1992
|
|
|
1711
1993
|
const expectedRender = `
|
|
1712
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
1994
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
1713
1995
|
const elms = []
|
|
1714
1996
|
let componentType
|
|
1715
1997
|
const rootComponent = component
|
|
1716
1998
|
let propData
|
|
1999
|
+
let slotComponent
|
|
2000
|
+
let inSlot = false
|
|
2001
|
+
let slotChildCounter = 0
|
|
1717
2002
|
const elementConfig0 = {}
|
|
1718
2003
|
|
|
1719
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2004
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1720
2005
|
elms[0].populate(elementConfig0)
|
|
1721
|
-
parent = elms[0]
|
|
1722
2006
|
|
|
2007
|
+
if (inSlot === true) {
|
|
2008
|
+
slotChildCounter -= 1
|
|
2009
|
+
}
|
|
2010
|
+
parent = elms[0]
|
|
1723
2011
|
const elementConfig1 = {}
|
|
1724
|
-
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
2012
|
+
elms[1] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1725
2013
|
elementConfig1['w'] = 1920
|
|
1726
2014
|
elementConfig1['h'] = 1080
|
|
1727
2015
|
elms[1].populate(elementConfig1)
|
|
1728
|
-
parent = elms[1]
|
|
1729
2016
|
|
|
2017
|
+
if (inSlot === true) {
|
|
2018
|
+
slotChildCounter -= 1
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
parent = elms[1]
|
|
1730
2022
|
const elementConfig2 = {}
|
|
1731
|
-
elms[2] = this.element({ parent: parent || 'root' }, component)
|
|
2023
|
+
elms[2] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1732
2024
|
elementConfig2[Symbol.for('isSlot')] = true
|
|
1733
2025
|
elementConfig2['x'] = 100
|
|
1734
2026
|
elementConfig2['y'] = component.y
|
|
1735
2027
|
elms[2].populate(elementConfig2)
|
|
2028
|
+
if (inSlot === true) {
|
|
2029
|
+
slotChildCounter -= 1
|
|
2030
|
+
}
|
|
1736
2031
|
|
|
1737
2032
|
return elms
|
|
1738
2033
|
}
|
|
@@ -1770,22 +2065,32 @@ test('Generate code for a template with inline Text', (assert) => {
|
|
|
1770
2065
|
}
|
|
1771
2066
|
|
|
1772
2067
|
const expectedRender = `
|
|
1773
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
2068
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
1774
2069
|
const elms = []
|
|
1775
2070
|
let componentType
|
|
1776
2071
|
const rootComponent = component
|
|
1777
2072
|
let propData
|
|
2073
|
+
let slotComponent
|
|
2074
|
+
let inSlot = false
|
|
2075
|
+
let slotChildCounter = 0
|
|
1778
2076
|
const elementConfig0 = {}
|
|
1779
2077
|
|
|
1780
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2078
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1781
2079
|
elms[0].populate(elementConfig0)
|
|
1782
|
-
parent = elms[0]
|
|
1783
2080
|
|
|
2081
|
+
if (inSlot === true) {
|
|
2082
|
+
slotChildCounter -= 1
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
parent = elms[0]
|
|
1784
2086
|
const elementConfig1 = {}
|
|
1785
|
-
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
2087
|
+
elms[1] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1786
2088
|
elementConfig1['content'] = 'HelloBlits!'
|
|
1787
2089
|
elementConfig1['__textnode'] = true
|
|
1788
2090
|
elms[1].populate(elementConfig1)
|
|
2091
|
+
if (inSlot === true) {
|
|
2092
|
+
slotChildCounter -= 1
|
|
2093
|
+
}
|
|
1789
2094
|
|
|
1790
2095
|
return elms
|
|
1791
2096
|
}
|
|
@@ -1821,23 +2126,34 @@ test('Generate code for a template with inline dynamic Text', (assert) => {
|
|
|
1821
2126
|
}
|
|
1822
2127
|
|
|
1823
2128
|
const expectedRender = `
|
|
1824
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
2129
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
1825
2130
|
const elms = []
|
|
1826
2131
|
let componentType
|
|
1827
2132
|
const rootComponent = component
|
|
1828
2133
|
let propData
|
|
2134
|
+
let slotComponent
|
|
2135
|
+
let inSlot = false
|
|
2136
|
+
let slotChildCounter = 0
|
|
1829
2137
|
const elementConfig0 = {}
|
|
1830
2138
|
|
|
1831
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2139
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1832
2140
|
elms[0].populate(elementConfig0)
|
|
1833
|
-
parent = elms[0]
|
|
1834
2141
|
|
|
2142
|
+
if (inSlot === true) {
|
|
2143
|
+
slotChildCounter -= 1
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
parent = elms[0]
|
|
1835
2147
|
const elementConfig1 = {}
|
|
1836
|
-
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
2148
|
+
elms[1] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1837
2149
|
elementConfig1['content'] = component.myText
|
|
1838
2150
|
elementConfig1['__textnode'] = true
|
|
1839
2151
|
elms[1].populate(elementConfig1)
|
|
1840
2152
|
|
|
2153
|
+
if (inSlot === true) {
|
|
2154
|
+
slotChildCounter -= 1
|
|
2155
|
+
}
|
|
2156
|
+
|
|
1841
2157
|
return elms
|
|
1842
2158
|
}
|
|
1843
2159
|
`
|
|
@@ -1872,23 +2188,33 @@ test('Generate code for a template with inline dynamic Text embedded in static t
|
|
|
1872
2188
|
}
|
|
1873
2189
|
|
|
1874
2190
|
const expectedRender = `
|
|
1875
|
-
function anonymous(parent,
|
|
2191
|
+
function anonymous(parent,component,context,components,effect,getRaw,Log) {
|
|
1876
2192
|
const elms = []
|
|
1877
2193
|
let componentType
|
|
1878
2194
|
const rootComponent = component
|
|
1879
2195
|
let propData
|
|
2196
|
+
let slotComponent
|
|
2197
|
+
let inSlot = false
|
|
2198
|
+
let slotChildCounter = 0
|
|
1880
2199
|
const elementConfig0 = {}
|
|
1881
2200
|
|
|
1882
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2201
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1883
2202
|
elms[0].populate(elementConfig0)
|
|
1884
|
-
|
|
2203
|
+
if(inSlot === true) {
|
|
2204
|
+
slotChildCounter -= 1
|
|
2205
|
+
}
|
|
1885
2206
|
|
|
2207
|
+
parent = elms[0]
|
|
1886
2208
|
const elementConfig1 = {}
|
|
1887
|
-
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
1888
|
-
elementConfig1['content'] = 'Hello'
|
|
2209
|
+
elms[1] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
2210
|
+
elementConfig1['content'] = 'Hello '+component.firstname+' '+component.lastname+', how are you?'
|
|
1889
2211
|
elementConfig1['__textnode'] = true
|
|
1890
2212
|
elms[1].populate(elementConfig1)
|
|
1891
2213
|
|
|
2214
|
+
if(inSlot === true) {
|
|
2215
|
+
slotChildCounter -= 1
|
|
2216
|
+
}
|
|
2217
|
+
|
|
1892
2218
|
return elms
|
|
1893
2219
|
}
|
|
1894
2220
|
`
|
|
@@ -1928,26 +2254,36 @@ test('Generate code for a template with a single element with attributes with pe
|
|
|
1928
2254
|
}
|
|
1929
2255
|
|
|
1930
2256
|
const expectedRender = `
|
|
1931
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
2257
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
1932
2258
|
const elms = []
|
|
1933
2259
|
let componentType
|
|
1934
2260
|
const rootComponent = component
|
|
1935
2261
|
let propData
|
|
2262
|
+
let slotComponent
|
|
2263
|
+
let inSlot = false
|
|
2264
|
+
let slotChildCounter = 0
|
|
1936
2265
|
const elementConfig0 = {}
|
|
1937
2266
|
|
|
1938
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2267
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1939
2268
|
elementConfig0['w'] = 1920
|
|
1940
2269
|
elementConfig0['h'] = 1080
|
|
1941
2270
|
elms[0].populate(elementConfig0)
|
|
1942
|
-
parent = elms[0]
|
|
1943
2271
|
|
|
2272
|
+
if(inSlot === true) {
|
|
2273
|
+
slotChildCounter -= 1
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
parent = elms[0]
|
|
1944
2277
|
const elementConfig1 = {}
|
|
1945
|
-
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
2278
|
+
elms[1] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
1946
2279
|
elementConfig1['w'] = parent.node.width * (50 / 100)
|
|
1947
2280
|
elementConfig1['h'] = parent.node.height * (40 / 100)
|
|
1948
2281
|
elementConfig1['x'] = parent.node.width * (10 / 100)
|
|
1949
2282
|
elementConfig1['y'] = parent.node.height * (20 / 100)
|
|
1950
2283
|
elms[1].populate(elementConfig1)
|
|
2284
|
+
if(inSlot === true) {
|
|
2285
|
+
slotChildCounter -= 1
|
|
2286
|
+
}
|
|
1951
2287
|
|
|
1952
2288
|
return elms
|
|
1953
2289
|
}
|
|
@@ -1983,25 +2319,41 @@ test('Generate code for a template with a simple for-loop on an Element', (asser
|
|
|
1983
2319
|
}
|
|
1984
2320
|
|
|
1985
2321
|
const expectedRender = `
|
|
1986
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
2322
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
1987
2323
|
const elms = []
|
|
1988
2324
|
let componentType
|
|
1989
2325
|
const rootComponent = component
|
|
1990
2326
|
let propData
|
|
2327
|
+
let slotComponent
|
|
2328
|
+
let inSlot = false
|
|
2329
|
+
let slotChildCounter = 0
|
|
1991
2330
|
const elementConfig0 = {}
|
|
1992
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2331
|
+
elms[0] = this.element({ parent: parent || 'root' },inSlot === true ? slotComponent : component)
|
|
1993
2332
|
elms[0].populate(elementConfig0)
|
|
2333
|
+
if (inSlot === true) {
|
|
2334
|
+
slotChildCounter -= 1
|
|
2335
|
+
}
|
|
2336
|
+
|
|
1994
2337
|
parent = elms[0]
|
|
1995
2338
|
const created1 = []
|
|
2339
|
+
let from1
|
|
2340
|
+
let to1
|
|
1996
2341
|
const forloop1 = (collection = [], elms, created) => {
|
|
1997
2342
|
const rawCollection = getRaw(collection)
|
|
1998
2343
|
const keys = new Set()
|
|
1999
2344
|
let l = rawCollection.length
|
|
2345
|
+
const range = {} || {}
|
|
2346
|
+
|
|
2347
|
+
from1 = range['from'] || 0
|
|
2348
|
+
to1 = 'to' in range ? range['to'] : rawCollection.length
|
|
2349
|
+
|
|
2000
2350
|
while (l--) {
|
|
2001
2351
|
const item = rawCollection[l]
|
|
2002
|
-
|
|
2003
|
-
|
|
2352
|
+
if (l < to1 && l >= from1) {
|
|
2353
|
+
keys.add('' + l)
|
|
2354
|
+
}
|
|
2004
2355
|
}
|
|
2356
|
+
|
|
2005
2357
|
let i = created.length
|
|
2006
2358
|
while (i--) {
|
|
2007
2359
|
if (keys.has(created[i]) === false) {
|
|
@@ -2012,11 +2364,13 @@ test('Generate code for a template with a simple for-loop on an Element', (asser
|
|
|
2012
2364
|
}
|
|
2013
2365
|
created.length = 0
|
|
2014
2366
|
const length = rawCollection.length
|
|
2367
|
+
const effects = []
|
|
2015
2368
|
for (let __index = 0; __index < length; __index++) {
|
|
2369
|
+
if (__index < from1 || __index >= to1) continue
|
|
2016
2370
|
const scope = Object.create(component)
|
|
2017
2371
|
parent = elms[0]
|
|
2018
|
-
scope['index'] = __index
|
|
2019
2372
|
scope['item'] = rawCollection[__index]
|
|
2373
|
+
scope['undefined'] = __index
|
|
2020
2374
|
scope['key'] = '' + __index
|
|
2021
2375
|
created.push(scope.key)
|
|
2022
2376
|
parent = elms[0]
|
|
@@ -2025,16 +2379,25 @@ test('Generate code for a template with a simple for-loop on an Element', (asser
|
|
|
2025
2379
|
}
|
|
2026
2380
|
const elementConfig1 = {}
|
|
2027
2381
|
if (elms[1][scope.key] === undefined) {
|
|
2028
|
-
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
2382
|
+
elms[1][scope.key] = this.element({ parent: parent || 'root' },inSlot === true ? slotComponent : component)
|
|
2029
2383
|
}
|
|
2030
2384
|
if (elms[1][scope.key].nodeId === undefined) {
|
|
2031
2385
|
elms[1][scope.key].populate(elementConfig1)
|
|
2386
|
+
if (inSlot === true) {
|
|
2387
|
+
slotChildCounter -= 1
|
|
2388
|
+
}
|
|
2032
2389
|
}
|
|
2033
2390
|
}
|
|
2391
|
+
return effects
|
|
2034
2392
|
}
|
|
2393
|
+
|
|
2394
|
+
let forEffects1
|
|
2395
|
+
|
|
2035
2396
|
effect(() => {
|
|
2036
|
-
|
|
2037
|
-
|
|
2397
|
+
component[Symbol.for('removeGlobalEffects')](forEffects1)
|
|
2398
|
+
forEffects1 = null
|
|
2399
|
+
forEffects1 = forloop1(component.items, elms, created1)
|
|
2400
|
+
}, ['items',])
|
|
2038
2401
|
return elms
|
|
2039
2402
|
}
|
|
2040
2403
|
`
|
|
@@ -2071,25 +2434,41 @@ test('Generate code for a template with a simple for-loop on an Element, Using d
|
|
|
2071
2434
|
}
|
|
2072
2435
|
|
|
2073
2436
|
const expectedRender = `
|
|
2074
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
2437
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
2075
2438
|
const elms = []
|
|
2076
2439
|
let componentType
|
|
2077
2440
|
const rootComponent = component
|
|
2078
2441
|
let propData
|
|
2442
|
+
let slotComponent
|
|
2443
|
+
let inSlot = false
|
|
2444
|
+
let slotChildCounter = 0
|
|
2079
2445
|
const elementConfig0 = {}
|
|
2080
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2446
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
2081
2447
|
elms[0].populate(elementConfig0)
|
|
2448
|
+
if (inSlot === true) {
|
|
2449
|
+
slotChildCounter -= 1
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2082
2452
|
parent = elms[0]
|
|
2083
2453
|
const created1 = []
|
|
2454
|
+
let from1
|
|
2455
|
+
let to1
|
|
2084
2456
|
const forloop1 = (collection = [], elms, created) => {
|
|
2085
2457
|
const rawCollection = getRaw(collection)
|
|
2086
2458
|
const keys = new Set()
|
|
2087
2459
|
let l = rawCollection.length
|
|
2460
|
+
const range = {} || {}
|
|
2461
|
+
|
|
2462
|
+
from1 = range['from'] || 0
|
|
2463
|
+
to1 = 'to' in range ? range['to'] : rawCollection.length
|
|
2464
|
+
|
|
2088
2465
|
while (l--) {
|
|
2089
2466
|
const item = rawCollection[l]
|
|
2090
|
-
|
|
2091
|
-
|
|
2467
|
+
if (l < to1 && l >= from1) {
|
|
2468
|
+
keys.add('' + l)
|
|
2469
|
+
}
|
|
2092
2470
|
}
|
|
2471
|
+
|
|
2093
2472
|
let i = created.length
|
|
2094
2473
|
while (i--) {
|
|
2095
2474
|
if (keys.has(created[i]) === false) {
|
|
@@ -2100,11 +2479,13 @@ test('Generate code for a template with a simple for-loop on an Element, Using d
|
|
|
2100
2479
|
}
|
|
2101
2480
|
created.length = 0
|
|
2102
2481
|
const length = rawCollection.length
|
|
2482
|
+
const effects = []
|
|
2103
2483
|
for (let __index = 0; __index < length; __index++) {
|
|
2484
|
+
if (__index < from1 || __index >= to1) continue
|
|
2104
2485
|
const scope = Object.create(component)
|
|
2105
2486
|
parent = elms[0]
|
|
2106
|
-
scope['index'] = __index
|
|
2107
2487
|
scope['item'] = rawCollection[__index]
|
|
2488
|
+
scope['undefined'] = __index
|
|
2108
2489
|
scope['key'] = '' + __index
|
|
2109
2490
|
created.push(scope.key)
|
|
2110
2491
|
parent = elms[0]
|
|
@@ -2113,16 +2494,25 @@ test('Generate code for a template with a simple for-loop on an Element, Using d
|
|
|
2113
2494
|
}
|
|
2114
2495
|
const elementConfig1 = {}
|
|
2115
2496
|
if (elms[1][scope.key] === undefined) {
|
|
2116
|
-
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
2497
|
+
elms[1][scope.key] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
2117
2498
|
}
|
|
2118
2499
|
if (elms[1][scope.key].nodeId === undefined) {
|
|
2119
2500
|
elms[1][scope.key].populate(elementConfig1)
|
|
2501
|
+
if (inSlot === true) {
|
|
2502
|
+
slotChildCounter -= 1
|
|
2503
|
+
}
|
|
2120
2504
|
}
|
|
2121
2505
|
}
|
|
2506
|
+
return effects
|
|
2122
2507
|
}
|
|
2508
|
+
|
|
2509
|
+
let forEffects1
|
|
2510
|
+
|
|
2123
2511
|
effect(() => {
|
|
2124
|
-
|
|
2125
|
-
|
|
2512
|
+
component[Symbol.for('removeGlobalEffects')](forEffects1)
|
|
2513
|
+
forEffects1 = null
|
|
2514
|
+
forEffects1 = forloop1(component.$appState.list, elms, created1)
|
|
2515
|
+
}, ['list',])
|
|
2126
2516
|
return elms
|
|
2127
2517
|
}
|
|
2128
2518
|
`
|
|
@@ -2159,25 +2549,41 @@ test('Generate code for a template with a simple for-loop on an Element, Using d
|
|
|
2159
2549
|
}
|
|
2160
2550
|
|
|
2161
2551
|
const expectedRender = `
|
|
2162
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
2552
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
2163
2553
|
const elms = []
|
|
2164
2554
|
let componentType
|
|
2165
2555
|
const rootComponent = component
|
|
2166
2556
|
let propData
|
|
2557
|
+
let slotComponent
|
|
2558
|
+
let inSlot = false
|
|
2559
|
+
let slotChildCounter = 0
|
|
2167
2560
|
const elementConfig0 = {}
|
|
2168
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2561
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
2169
2562
|
elms[0].populate(elementConfig0)
|
|
2563
|
+
if (inSlot === true) {
|
|
2564
|
+
slotChildCounter -= 1
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2170
2567
|
parent = elms[0]
|
|
2171
2568
|
const created1 = []
|
|
2569
|
+
let from1
|
|
2570
|
+
let to1
|
|
2172
2571
|
const forloop1 = (collection = [], elms, created) => {
|
|
2173
2572
|
const rawCollection = getRaw(collection)
|
|
2174
2573
|
const keys = new Set()
|
|
2175
2574
|
let l = rawCollection.length
|
|
2575
|
+
const range = {} || {}
|
|
2576
|
+
|
|
2577
|
+
from1 = range['from'] || 0
|
|
2578
|
+
to1 = 'to' in range ? range['to'] : rawCollection.length
|
|
2579
|
+
|
|
2176
2580
|
while (l--) {
|
|
2177
2581
|
const item = rawCollection[l]
|
|
2178
|
-
|
|
2179
|
-
|
|
2582
|
+
if (l < to1 && l >= from1) {
|
|
2583
|
+
keys.add('' + l)
|
|
2584
|
+
}
|
|
2180
2585
|
}
|
|
2586
|
+
|
|
2181
2587
|
let i = created.length
|
|
2182
2588
|
while (i--) {
|
|
2183
2589
|
if (keys.has(created[i]) === false) {
|
|
@@ -2188,11 +2594,14 @@ test('Generate code for a template with a simple for-loop on an Element, Using d
|
|
|
2188
2594
|
}
|
|
2189
2595
|
created.length = 0
|
|
2190
2596
|
const length = rawCollection.length
|
|
2597
|
+
const effects = []
|
|
2598
|
+
|
|
2191
2599
|
for (let __index = 0; __index < length; __index++) {
|
|
2600
|
+
if (__index < from1 || __index >= to1) continue
|
|
2192
2601
|
const scope = Object.create(component)
|
|
2193
2602
|
parent = elms[0]
|
|
2194
|
-
scope['index'] = __index
|
|
2195
2603
|
scope['item'] = rawCollection[__index]
|
|
2604
|
+
scope['undefined'] = __index
|
|
2196
2605
|
scope['key'] = '' + __index
|
|
2197
2606
|
created.push(scope.key)
|
|
2198
2607
|
parent = elms[0]
|
|
@@ -2201,16 +2610,27 @@ test('Generate code for a template with a simple for-loop on an Element, Using d
|
|
|
2201
2610
|
}
|
|
2202
2611
|
const elementConfig1 = {}
|
|
2203
2612
|
if (elms[1][scope.key] === undefined) {
|
|
2204
|
-
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
2613
|
+
elms[1][scope.key] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
2205
2614
|
}
|
|
2206
2615
|
if (elms[1][scope.key].nodeId === undefined) {
|
|
2207
2616
|
elms[1][scope.key].populate(elementConfig1)
|
|
2617
|
+
if (inSlot === true) {
|
|
2618
|
+
slotChildCounter -= 1
|
|
2619
|
+
}
|
|
2208
2620
|
}
|
|
2209
2621
|
}
|
|
2622
|
+
|
|
2623
|
+
return effects
|
|
2210
2624
|
}
|
|
2625
|
+
|
|
2626
|
+
let forEffects1
|
|
2627
|
+
|
|
2211
2628
|
effect(() => {
|
|
2212
|
-
|
|
2213
|
-
|
|
2629
|
+
component[Symbol.for('removeGlobalEffects')](forEffects1)
|
|
2630
|
+
forEffects1 = null
|
|
2631
|
+
forEffects1 = forloop1(component.content.data, elms, created1)
|
|
2632
|
+
}, ['data',])
|
|
2633
|
+
|
|
2214
2634
|
return elms
|
|
2215
2635
|
}
|
|
2216
2636
|
`
|
|
@@ -2247,25 +2667,41 @@ test('Generate code for a template with a simple for-loop on an Element with a c
|
|
|
2247
2667
|
}
|
|
2248
2668
|
|
|
2249
2669
|
const expectedRender = `
|
|
2250
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
2670
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
2251
2671
|
const elms = []
|
|
2252
2672
|
let componentType
|
|
2253
2673
|
const rootComponent = component
|
|
2254
2674
|
let propData
|
|
2675
|
+
let slotComponent
|
|
2676
|
+
let inSlot = false
|
|
2677
|
+
let slotChildCounter = 0
|
|
2255
2678
|
const elementConfig0 = {}
|
|
2256
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2679
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
2257
2680
|
elms[0].populate(elementConfig0)
|
|
2681
|
+
if (inSlot === true) {
|
|
2682
|
+
slotChildCounter -= 1
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2258
2685
|
parent = elms[0]
|
|
2259
2686
|
const created1 = []
|
|
2687
|
+
let from1
|
|
2688
|
+
let to1
|
|
2260
2689
|
const forloop1 = (collection = [], elms, created) => {
|
|
2261
2690
|
const rawCollection = getRaw(collection)
|
|
2262
2691
|
const keys = new Set()
|
|
2263
2692
|
let l = rawCollection.length
|
|
2693
|
+
const range = {} || {}
|
|
2694
|
+
|
|
2695
|
+
from1 = range['from'] || 0
|
|
2696
|
+
to1 = 'to' in range ? range['to'] : rawCollection.length
|
|
2264
2697
|
while (l--) {
|
|
2265
2698
|
const item = rawCollection[l]
|
|
2266
2699
|
const customIndex = l
|
|
2267
|
-
|
|
2700
|
+
if (l < to1 && l >= from1) {
|
|
2701
|
+
keys.add('' + l)
|
|
2702
|
+
}
|
|
2268
2703
|
}
|
|
2704
|
+
|
|
2269
2705
|
let i = created.length
|
|
2270
2706
|
while (i--) {
|
|
2271
2707
|
if (keys.has(created[i]) === false) {
|
|
@@ -2276,11 +2712,13 @@ test('Generate code for a template with a simple for-loop on an Element with a c
|
|
|
2276
2712
|
}
|
|
2277
2713
|
created.length = 0
|
|
2278
2714
|
const length = rawCollection.length
|
|
2715
|
+
const effects = []
|
|
2279
2716
|
for (let __index = 0; __index < length; __index++) {
|
|
2717
|
+
if (__index < from1 || __index >= to1) continue
|
|
2280
2718
|
const scope = Object.create(component)
|
|
2281
2719
|
parent = elms[0]
|
|
2282
|
-
scope['customIndex'] = __index
|
|
2283
2720
|
scope['item'] = rawCollection[__index]
|
|
2721
|
+
scope['customIndex'] = __index
|
|
2284
2722
|
scope['key'] = '' + __index
|
|
2285
2723
|
created.push(scope.key)
|
|
2286
2724
|
parent = elms[0]
|
|
@@ -2289,16 +2727,27 @@ test('Generate code for a template with a simple for-loop on an Element with a c
|
|
|
2289
2727
|
}
|
|
2290
2728
|
const elementConfig1 = {}
|
|
2291
2729
|
if (elms[1][scope.key] === undefined) {
|
|
2292
|
-
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
2730
|
+
elms[1][scope.key] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
2293
2731
|
}
|
|
2294
2732
|
if (elms[1][scope.key].nodeId === undefined) {
|
|
2295
|
-
|
|
2733
|
+
elms[1][scope.key].populate(elementConfig1)
|
|
2734
|
+
if (inSlot === true) {
|
|
2735
|
+
slotChildCounter -= 1
|
|
2736
|
+
}
|
|
2296
2737
|
}
|
|
2297
2738
|
}
|
|
2739
|
+
|
|
2740
|
+
return effects
|
|
2298
2741
|
}
|
|
2742
|
+
|
|
2743
|
+
let forEffects1
|
|
2744
|
+
|
|
2299
2745
|
effect(() => {
|
|
2300
|
-
|
|
2301
|
-
|
|
2746
|
+
component[Symbol.for('removeGlobalEffects')](forEffects1)
|
|
2747
|
+
forEffects1 = null
|
|
2748
|
+
forEffects1 = forloop1(component.items, elms, created1)
|
|
2749
|
+
}, ['items',])
|
|
2750
|
+
|
|
2302
2751
|
return elms
|
|
2303
2752
|
}
|
|
2304
2753
|
`
|
|
@@ -2336,25 +2785,40 @@ test('Generate code for a template with a simple for-loop on an Element with a k
|
|
|
2336
2785
|
}
|
|
2337
2786
|
|
|
2338
2787
|
const expectedRender = `
|
|
2339
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
2788
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
2340
2789
|
const elms = []
|
|
2341
2790
|
let componentType
|
|
2342
2791
|
const rootComponent = component
|
|
2343
2792
|
let propData
|
|
2793
|
+
let slotComponent
|
|
2794
|
+
let inSlot = false
|
|
2795
|
+
let slotChildCounter = 0
|
|
2344
2796
|
const elementConfig0 = {}
|
|
2345
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2797
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
2346
2798
|
elms[0].populate(elementConfig0)
|
|
2799
|
+
if (inSlot === true) {
|
|
2800
|
+
slotChildCounter -= 1
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2347
2803
|
parent = elms[0]
|
|
2348
2804
|
const created1 = []
|
|
2805
|
+
let from1
|
|
2806
|
+
let to1
|
|
2349
2807
|
const forloop1 = (collection = [], elms, created) => {
|
|
2350
2808
|
const rawCollection = getRaw(collection)
|
|
2351
2809
|
const keys = new Set()
|
|
2352
2810
|
let l = rawCollection.length
|
|
2811
|
+
const range = {} || {}
|
|
2812
|
+
|
|
2813
|
+
from1 = range['from'] || 0
|
|
2814
|
+
to1 = 'to' in range ? range['to'] : rawCollection.length
|
|
2353
2815
|
while (l--) {
|
|
2354
2816
|
const item = rawCollection[l]
|
|
2355
|
-
|
|
2356
|
-
|
|
2817
|
+
if (l < to1 && l >= from1) {
|
|
2818
|
+
keys.add('' + item.id)
|
|
2819
|
+
}
|
|
2357
2820
|
}
|
|
2821
|
+
|
|
2358
2822
|
let i = created.length
|
|
2359
2823
|
while (i--) {
|
|
2360
2824
|
if (keys.has(created[i]) === false) {
|
|
@@ -2365,11 +2829,13 @@ test('Generate code for a template with a simple for-loop on an Element with a k
|
|
|
2365
2829
|
}
|
|
2366
2830
|
created.length = 0
|
|
2367
2831
|
const length = rawCollection.length
|
|
2832
|
+
const effects = []
|
|
2368
2833
|
for (let __index = 0; __index < length; __index++) {
|
|
2834
|
+
if (__index < from1 || __index >= to1) continue
|
|
2369
2835
|
const scope = Object.create(component)
|
|
2370
2836
|
parent = elms[0]
|
|
2371
|
-
scope['index'] = __index
|
|
2372
2837
|
scope['item'] = rawCollection[__index]
|
|
2838
|
+
scope['undefined'] = __index
|
|
2373
2839
|
scope['key'] = '' + scope.item.id
|
|
2374
2840
|
created.push(scope.key)
|
|
2375
2841
|
parent = elms[0]
|
|
@@ -2378,16 +2844,27 @@ test('Generate code for a template with a simple for-loop on an Element with a k
|
|
|
2378
2844
|
}
|
|
2379
2845
|
const elementConfig1 = {}
|
|
2380
2846
|
if (elms[1][scope.key] === undefined) {
|
|
2381
|
-
|
|
2847
|
+
elms[1][scope.key] = this.element({ parent: parent || 'root' },inSlot === true ? slotComponent : component)
|
|
2382
2848
|
}
|
|
2383
2849
|
if (elms[1][scope.key].nodeId === undefined) {
|
|
2384
2850
|
elms[1][scope.key].populate(elementConfig1)
|
|
2851
|
+
if (inSlot === true) {
|
|
2852
|
+
slotChildCounter -= 1
|
|
2853
|
+
}
|
|
2385
2854
|
}
|
|
2386
2855
|
}
|
|
2856
|
+
|
|
2857
|
+
return effects
|
|
2387
2858
|
}
|
|
2859
|
+
|
|
2860
|
+
let forEffects1
|
|
2861
|
+
|
|
2388
2862
|
effect(() => {
|
|
2389
|
-
|
|
2390
|
-
|
|
2863
|
+
component[Symbol.for('removeGlobalEffects')](forEffects1)
|
|
2864
|
+
forEffects1 = null
|
|
2865
|
+
forEffects1 = forloop1(component.items, elms, created1)
|
|
2866
|
+
}, ['items',])
|
|
2867
|
+
|
|
2391
2868
|
return elms
|
|
2392
2869
|
}
|
|
2393
2870
|
`
|
|
@@ -2425,25 +2902,42 @@ test('Generate code for a template with a simple for-loop on a Component with a
|
|
|
2425
2902
|
}
|
|
2426
2903
|
|
|
2427
2904
|
const expectedRender = `
|
|
2428
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
2905
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
2429
2906
|
const elms = []
|
|
2430
2907
|
let componentType
|
|
2431
2908
|
const rootComponent = component
|
|
2432
2909
|
let propData
|
|
2910
|
+
let slotComponent
|
|
2911
|
+
let inSlot = false
|
|
2912
|
+
let slotChildCounter = 0
|
|
2433
2913
|
const elementConfig0 = {}
|
|
2434
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2914
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
2435
2915
|
elms[0].populate(elementConfig0)
|
|
2916
|
+
if (inSlot === true) {
|
|
2917
|
+
slotChildCounter -= 1
|
|
2918
|
+
}
|
|
2919
|
+
|
|
2436
2920
|
parent = elms[0]
|
|
2437
2921
|
const created1 = []
|
|
2922
|
+
let from1
|
|
2923
|
+
let to1
|
|
2438
2924
|
const forloop1 = (collection = [], elms, created) => {
|
|
2439
2925
|
const rawCollection = getRaw(collection)
|
|
2440
2926
|
const keys = new Set()
|
|
2441
2927
|
let l = rawCollection.length
|
|
2928
|
+
const range = {} || {}
|
|
2929
|
+
|
|
2930
|
+
from1 = range['from'] || 0
|
|
2931
|
+
to1 = 'to' in range ? range['to'] : rawCollection.length
|
|
2932
|
+
|
|
2442
2933
|
while (l--) {
|
|
2443
2934
|
const item = rawCollection[l]
|
|
2444
2935
|
const myIndex = l
|
|
2445
|
-
|
|
2936
|
+
if (l < to1 && l >= from1) {
|
|
2937
|
+
keys.add('' + item.id)
|
|
2938
|
+
}
|
|
2446
2939
|
}
|
|
2940
|
+
|
|
2447
2941
|
let i = created.length
|
|
2448
2942
|
while (i--) {
|
|
2449
2943
|
if (keys.has(created[i]) === false) {
|
|
@@ -2456,11 +2950,14 @@ test('Generate code for a template with a simple for-loop on a Component with a
|
|
|
2456
2950
|
}
|
|
2457
2951
|
created.length = 0
|
|
2458
2952
|
const length = rawCollection.length
|
|
2953
|
+
const effects = []
|
|
2459
2954
|
for (let __index = 0; __index < length; __index++) {
|
|
2955
|
+
if (__index < from1 || __index >= to1) continue
|
|
2956
|
+
|
|
2460
2957
|
const scope = Object.create(component)
|
|
2461
2958
|
parent = elms[0]
|
|
2462
|
-
scope['myIndex'] = __index
|
|
2463
2959
|
scope['item'] = rawCollection[__index]
|
|
2960
|
+
scope['myIndex'] = __index
|
|
2464
2961
|
scope['key'] = '' + item.id
|
|
2465
2962
|
created.push(scope.key)
|
|
2466
2963
|
const cmp1 = (context.components && context.components['ListItem']) || components['ListItem']
|
|
@@ -2469,7 +2966,7 @@ test('Generate code for a template with a simple for-loop on a Component with a
|
|
|
2469
2966
|
}
|
|
2470
2967
|
const elementConfig1 = {}
|
|
2471
2968
|
if (elms[1][scope.key] === undefined) {
|
|
2472
|
-
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
2969
|
+
elms[1][scope.key] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
2473
2970
|
}
|
|
2474
2971
|
const skip1 = []
|
|
2475
2972
|
if (typeof cmp1 !== 'undefined') {
|
|
@@ -2480,6 +2977,9 @@ test('Generate code for a template with a simple for-loop on a Component with a
|
|
|
2480
2977
|
}
|
|
2481
2978
|
if (elms[1][scope.key].nodeId === undefined) {
|
|
2482
2979
|
elms[1][scope.key].populate(elementConfig1)
|
|
2980
|
+
if (inSlot === true) {
|
|
2981
|
+
slotChildCounter -= 1
|
|
2982
|
+
}
|
|
2483
2983
|
}
|
|
2484
2984
|
if (elms[2] === undefined) {
|
|
2485
2985
|
elms[2] = {}
|
|
@@ -2500,16 +3000,25 @@ test('Generate code for a template with a simple for-loop on a Component with a
|
|
|
2500
3000
|
elms[2][scope.key] = component2.call(null, { props: props2 }, elms[1][scope.key], component)
|
|
2501
3001
|
if (elms[2][scope.key][Symbol.for('slots')][0]) {
|
|
2502
3002
|
parent = elms[2][scope.key][Symbol.for('slots')][0]
|
|
2503
|
-
|
|
3003
|
+
slotComponent = elms[2][scope.key]
|
|
3004
|
+
inSlot = true
|
|
2504
3005
|
} else {
|
|
2505
3006
|
parent = elms[2][scope.key][Symbol.for('children')][0]
|
|
2506
3007
|
}
|
|
2507
3008
|
}
|
|
2508
3009
|
}
|
|
3010
|
+
|
|
3011
|
+
return effects
|
|
2509
3012
|
}
|
|
3013
|
+
|
|
3014
|
+
let forEffects1
|
|
3015
|
+
|
|
2510
3016
|
effect(() => {
|
|
2511
|
-
|
|
2512
|
-
|
|
3017
|
+
component[Symbol.for('removeGlobalEffects')](forEffects1)
|
|
3018
|
+
forEffects1 = null
|
|
3019
|
+
forEffects1 = forloop1(component.items, elms, created1)
|
|
3020
|
+
}, ['items',])
|
|
3021
|
+
|
|
2513
3022
|
return elms
|
|
2514
3023
|
}
|
|
2515
3024
|
`
|
|
@@ -2548,25 +3057,41 @@ test('Generate code for a template with a simple for-loop on an Element with an
|
|
|
2548
3057
|
}
|
|
2549
3058
|
|
|
2550
3059
|
const expectedRender = `
|
|
2551
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
3060
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
2552
3061
|
const elms = []
|
|
2553
3062
|
let componentType
|
|
2554
3063
|
const rootComponent = component
|
|
2555
3064
|
let propData
|
|
3065
|
+
let slotComponent
|
|
3066
|
+
let inSlot = false
|
|
3067
|
+
let slotChildCounter = 0
|
|
2556
3068
|
const elementConfig0 = {}
|
|
2557
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
3069
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
2558
3070
|
elms[0].populate(elementConfig0)
|
|
3071
|
+
if (inSlot === true) {
|
|
3072
|
+
slotChildCounter -= 1
|
|
3073
|
+
}
|
|
3074
|
+
|
|
2559
3075
|
parent = elms[0]
|
|
2560
3076
|
const created1 = []
|
|
3077
|
+
let from1
|
|
3078
|
+
let to1
|
|
2561
3079
|
const forloop1 = (collection = [], elms, created) => {
|
|
2562
3080
|
const rawCollection = getRaw(collection)
|
|
2563
3081
|
const keys = new Set()
|
|
2564
3082
|
let l = rawCollection.length
|
|
3083
|
+
const range = {} || {}
|
|
3084
|
+
|
|
3085
|
+
from1 = range['from'] || 0
|
|
3086
|
+
to1 = 'to' in range ? range['to'] : rawCollection.length
|
|
3087
|
+
|
|
2565
3088
|
while (l--) {
|
|
2566
3089
|
const item = rawCollection[l]
|
|
2567
|
-
|
|
2568
|
-
|
|
3090
|
+
if (l < to1 && l >= from1) {
|
|
3091
|
+
keys.add('' + item.id)
|
|
3092
|
+
}
|
|
2569
3093
|
}
|
|
3094
|
+
|
|
2570
3095
|
let i = created.length
|
|
2571
3096
|
while (i--) {
|
|
2572
3097
|
if (keys.has(created[i]) === false) {
|
|
@@ -2577,11 +3102,13 @@ test('Generate code for a template with a simple for-loop on an Element with an
|
|
|
2577
3102
|
}
|
|
2578
3103
|
created.length = 0
|
|
2579
3104
|
const length = rawCollection.length
|
|
3105
|
+
const effects = []
|
|
2580
3106
|
for (let __index = 0; __index < length; __index++) {
|
|
3107
|
+
if (__index < from1 || __index >= to1) continue
|
|
2581
3108
|
const scope = Object.create(component)
|
|
2582
3109
|
parent = elms[0]
|
|
2583
|
-
scope['index'] = __index
|
|
2584
3110
|
scope['item'] = rawCollection[__index]
|
|
3111
|
+
scope['undefined'] = __index
|
|
2585
3112
|
scope['key'] = '' + item.id
|
|
2586
3113
|
scope['__ref'] = 'myref' + __index
|
|
2587
3114
|
created.push(scope.key)
|
|
@@ -2591,17 +3118,28 @@ test('Generate code for a template with a simple for-loop on an Element with an
|
|
|
2591
3118
|
}
|
|
2592
3119
|
const elementConfig1 = {}
|
|
2593
3120
|
if (elms[1][scope.key] === undefined) {
|
|
2594
|
-
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
3121
|
+
elms[1][scope.key] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
2595
3122
|
}
|
|
2596
3123
|
elementConfig1['ref'] = scope.__ref
|
|
2597
3124
|
if (elms[1][scope.key].nodeId === undefined) {
|
|
2598
3125
|
elms[1][scope.key].populate(elementConfig1)
|
|
3126
|
+
if (inSlot === true) {
|
|
3127
|
+
slotChildCounter -= 1
|
|
3128
|
+
}
|
|
2599
3129
|
}
|
|
2600
3130
|
}
|
|
3131
|
+
|
|
3132
|
+
return effects
|
|
2601
3133
|
}
|
|
3134
|
+
|
|
3135
|
+
let forEffects1
|
|
3136
|
+
|
|
2602
3137
|
effect(() => {
|
|
2603
|
-
|
|
2604
|
-
|
|
3138
|
+
component[Symbol.for('removeGlobalEffects')](forEffects1)
|
|
3139
|
+
forEffects1 = null
|
|
3140
|
+
forEffects1 = forloop1(component.items, elms, created1)
|
|
3141
|
+
}, ['items', ])
|
|
3142
|
+
|
|
2605
3143
|
return elms
|
|
2606
3144
|
}
|
|
2607
3145
|
`
|
|
@@ -2633,18 +3171,25 @@ test('Generate code for a template with double $$ (i.e. referencing a Blits plug
|
|
|
2633
3171
|
}
|
|
2634
3172
|
|
|
2635
3173
|
const expectedRender = `
|
|
2636
|
-
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
3174
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
2637
3175
|
const elms = []
|
|
2638
3176
|
let componentType
|
|
2639
3177
|
const rootComponent = component
|
|
2640
3178
|
let propData
|
|
3179
|
+
let slotComponent
|
|
3180
|
+
let inSlot = false
|
|
3181
|
+
let slotChildCounter = 0
|
|
2641
3182
|
const elementConfig0 = {}
|
|
2642
3183
|
|
|
2643
|
-
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
3184
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
2644
3185
|
elementConfig0['content'] = component.$language.translate('hello')
|
|
2645
3186
|
elementConfig0['__textnode'] = true
|
|
2646
3187
|
elms[0].populate(elementConfig0)
|
|
2647
3188
|
|
|
3189
|
+
if (inSlot === true) {
|
|
3190
|
+
slotChildCounter -= 1
|
|
3191
|
+
}
|
|
3192
|
+
|
|
2648
3193
|
return elms
|
|
2649
3194
|
}
|
|
2650
3195
|
`
|
|
@@ -2674,3 +3219,380 @@ test('Generate code for a template with double $$ (i.e. referencing a Blits plug
|
|
|
2674
3219
|
|
|
2675
3220
|
assert.end()
|
|
2676
3221
|
})
|
|
3222
|
+
|
|
3223
|
+
test('Generate code for a template with verification of dynamic attributes', (assert) => {
|
|
3224
|
+
const templateObject = {
|
|
3225
|
+
children: [
|
|
3226
|
+
{
|
|
3227
|
+
[Symbol.for('componentType')]: 'Element',
|
|
3228
|
+
w: '$eWidth',
|
|
3229
|
+
h: '$eHeight',
|
|
3230
|
+
},
|
|
3231
|
+
],
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
const expectedRender = `
|
|
3235
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
3236
|
+
const elms = []
|
|
3237
|
+
let componentType
|
|
3238
|
+
const rootComponent = component
|
|
3239
|
+
let propData
|
|
3240
|
+
let slotComponent
|
|
3241
|
+
let inSlot = false
|
|
3242
|
+
let slotChildCounter = 0
|
|
3243
|
+
|
|
3244
|
+
function propInComponent(prop, kind = "dynamic") {
|
|
3245
|
+
const property = prop.includes('.') ? prop.split('.')[0] : prop
|
|
3246
|
+
if (kind === 'reactive' || prop.includes('.') === false) {
|
|
3247
|
+
if (property in component === false) {
|
|
3248
|
+
Log.warn('Property ' + property + ' was accessed during render but is not defined on instance')
|
|
3249
|
+
}
|
|
3250
|
+
} else {
|
|
3251
|
+
const nestedKeys = prop.split('.')
|
|
3252
|
+
let base = component
|
|
3253
|
+
for (let i = 0; i < nestedKeys.length; i++) {
|
|
3254
|
+
if (base[nestedKeys[i]] === undefined) {
|
|
3255
|
+
Log.warn('Property ' + nestedKeys.slice(0, i + 1).join('.') + ' was accessed during render but is not defined on instance')
|
|
3256
|
+
}
|
|
3257
|
+
base = base[nestedKeys[i]]
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
|
|
3262
|
+
const elementConfig0 = {}
|
|
3263
|
+
|
|
3264
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
3265
|
+
|
|
3266
|
+
propInComponent('eWidth', 'dynamic')
|
|
3267
|
+
elementConfig0['w'] = component.eWidth
|
|
3268
|
+
propInComponent('eHeight', 'dynamic')
|
|
3269
|
+
elementConfig0['h'] = component.eHeight
|
|
3270
|
+
|
|
3271
|
+
elms[0].populate(elementConfig0)
|
|
3272
|
+
|
|
3273
|
+
if (inSlot === true) {
|
|
3274
|
+
slotChildCounter -= 1
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3277
|
+
return elms
|
|
3278
|
+
}
|
|
3279
|
+
`
|
|
3280
|
+
const actual = generator.call(scope, templateObject, true)
|
|
3281
|
+
|
|
3282
|
+
assert.equal(
|
|
3283
|
+
normalize(actual.render.toString()),
|
|
3284
|
+
normalize(expectedRender),
|
|
3285
|
+
'Generator should return a render function with the correct code'
|
|
3286
|
+
)
|
|
3287
|
+
assert.ok(
|
|
3288
|
+
Array.isArray(actual.effects) && actual.effects.length === 0,
|
|
3289
|
+
'Generator should return an empty effects array'
|
|
3290
|
+
)
|
|
3291
|
+
|
|
3292
|
+
assert.end()
|
|
3293
|
+
})
|
|
3294
|
+
|
|
3295
|
+
test('Generate code for a template with verification of reactive attributes', (assert) => {
|
|
3296
|
+
const templateObject = {
|
|
3297
|
+
children: [
|
|
3298
|
+
{
|
|
3299
|
+
[Symbol.for('componentType')]: 'Element',
|
|
3300
|
+
':w': '$eWidth',
|
|
3301
|
+
':h': '$eHeight',
|
|
3302
|
+
},
|
|
3303
|
+
],
|
|
3304
|
+
}
|
|
3305
|
+
|
|
3306
|
+
const expectedRender = `
|
|
3307
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
3308
|
+
const elms = []
|
|
3309
|
+
let componentType
|
|
3310
|
+
const rootComponent = component
|
|
3311
|
+
let propData
|
|
3312
|
+
let slotComponent
|
|
3313
|
+
let inSlot = false
|
|
3314
|
+
let slotChildCounter = 0
|
|
3315
|
+
|
|
3316
|
+
function propInComponent(prop, kind = "dynamic") {
|
|
3317
|
+
const property = prop.includes('.') ? prop.split('.')[0] : prop
|
|
3318
|
+
if (kind === 'reactive' || prop.includes('.') === false) {
|
|
3319
|
+
if (property in component === false) {
|
|
3320
|
+
Log.warn('Property ' + property + ' was accessed during render but is not defined on instance')
|
|
3321
|
+
}
|
|
3322
|
+
} else {
|
|
3323
|
+
const nestedKeys = prop.split('.')
|
|
3324
|
+
let base = component
|
|
3325
|
+
for (let i = 0; i < nestedKeys.length; i++) {
|
|
3326
|
+
if (base[nestedKeys[i]] === undefined) {
|
|
3327
|
+
Log.warn('Property ' + nestedKeys.slice(0, i + 1).join('.') + ' was accessed during render but is not defined on instance')
|
|
3328
|
+
}
|
|
3329
|
+
base = base[nestedKeys[i]]
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
|
|
3334
|
+
const elementConfig0 = {}
|
|
3335
|
+
|
|
3336
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
3337
|
+
|
|
3338
|
+
propInComponent('eWidth', 'reactive')
|
|
3339
|
+
elementConfig0['w'] = component.eWidth
|
|
3340
|
+
propInComponent('eHeight', 'reactive')
|
|
3341
|
+
elementConfig0['h'] = component.eHeight
|
|
3342
|
+
|
|
3343
|
+
elms[0].populate(elementConfig0)
|
|
3344
|
+
|
|
3345
|
+
if (inSlot === true) {
|
|
3346
|
+
slotChildCounter -= 1
|
|
3347
|
+
}
|
|
3348
|
+
|
|
3349
|
+
return elms
|
|
3350
|
+
}
|
|
3351
|
+
`
|
|
3352
|
+
const expectedEffect1 = `
|
|
3353
|
+
function anonymous(component, elms, context, components, rootComponent, effect) {
|
|
3354
|
+
elms[0].set('w', component.eWidth)
|
|
3355
|
+
}
|
|
3356
|
+
`
|
|
3357
|
+
|
|
3358
|
+
const expectedEffect2 = `
|
|
3359
|
+
function anonymous(component, elms, context, components, rootComponent, effect) {
|
|
3360
|
+
elms[0].set('h', component.eHeight)
|
|
3361
|
+
}
|
|
3362
|
+
`
|
|
3363
|
+
|
|
3364
|
+
const actual = generator.call(scope, templateObject, true)
|
|
3365
|
+
|
|
3366
|
+
assert.equal(
|
|
3367
|
+
normalize(actual.render.toString()),
|
|
3368
|
+
normalize(expectedRender),
|
|
3369
|
+
'Generator should return a render function with the correct code'
|
|
3370
|
+
)
|
|
3371
|
+
|
|
3372
|
+
assert.ok(
|
|
3373
|
+
Array.isArray(actual.effects) && actual.effects.length === 2,
|
|
3374
|
+
'Generator should return an effects array with 2 item'
|
|
3375
|
+
)
|
|
3376
|
+
|
|
3377
|
+
assert.equal(
|
|
3378
|
+
normalize(actual.effects[0].toString()),
|
|
3379
|
+
normalize(expectedEffect1),
|
|
3380
|
+
'Generator should return an effect function for the reactive eWidth attribute'
|
|
3381
|
+
)
|
|
3382
|
+
|
|
3383
|
+
assert.equal(
|
|
3384
|
+
normalize(actual.effects[1].toString()),
|
|
3385
|
+
normalize(expectedEffect2),
|
|
3386
|
+
'Generator should return an effect function for the reactive eHeight attribute'
|
|
3387
|
+
)
|
|
3388
|
+
|
|
3389
|
+
assert.end()
|
|
3390
|
+
})
|
|
3391
|
+
|
|
3392
|
+
test('Generate code for a template with attribute values verified against a nested state object', (assert) => {
|
|
3393
|
+
const templateObject = {
|
|
3394
|
+
children: [
|
|
3395
|
+
{
|
|
3396
|
+
[Symbol.for('componentType')]: 'Element',
|
|
3397
|
+
x: '$position.x',
|
|
3398
|
+
y: '$position.y',
|
|
3399
|
+
':w': '$size.w',
|
|
3400
|
+
':h': '$size.h',
|
|
3401
|
+
},
|
|
3402
|
+
],
|
|
3403
|
+
}
|
|
3404
|
+
|
|
3405
|
+
const expectedRender = `
|
|
3406
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
3407
|
+
const elms = []
|
|
3408
|
+
let componentType
|
|
3409
|
+
const rootComponent = component
|
|
3410
|
+
let propData
|
|
3411
|
+
let slotComponent
|
|
3412
|
+
let inSlot = false
|
|
3413
|
+
let slotChildCounter = 0
|
|
3414
|
+
|
|
3415
|
+
function propInComponent(prop, kind = "dynamic") {
|
|
3416
|
+
const property = prop.includes('.') ? prop.split('.')[0] : prop
|
|
3417
|
+
if (kind === 'reactive' || prop.includes('.') === false) {
|
|
3418
|
+
if (property in component === false) {
|
|
3419
|
+
Log.warn('Property ' + property + ' was accessed during render but is not defined on instance')
|
|
3420
|
+
}
|
|
3421
|
+
} else {
|
|
3422
|
+
const nestedKeys = prop.split('.')
|
|
3423
|
+
let base = component
|
|
3424
|
+
for (let i = 0; i < nestedKeys.length; i++) {
|
|
3425
|
+
if (base[nestedKeys[i]] === undefined) {
|
|
3426
|
+
Log.warn('Property ' + nestedKeys.slice(0, i + 1).join('.') + ' was accessed during render but is not defined on instance')
|
|
3427
|
+
}
|
|
3428
|
+
base = base[nestedKeys[i]]
|
|
3429
|
+
}
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
|
|
3433
|
+
const elementConfig0 = {}
|
|
3434
|
+
|
|
3435
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
3436
|
+
|
|
3437
|
+
propInComponent('position.x', 'dynamic')
|
|
3438
|
+
elementConfig0['x'] = component.position.x
|
|
3439
|
+
propInComponent('position.y', 'dynamic')
|
|
3440
|
+
elementConfig0['y'] = component.position.y
|
|
3441
|
+
propInComponent('size', 'reactive')
|
|
3442
|
+
elementConfig0['w'] = component.size.w
|
|
3443
|
+
propInComponent('size', 'reactive')
|
|
3444
|
+
elementConfig0['h'] = component.size.h
|
|
3445
|
+
|
|
3446
|
+
elms[0].populate(elementConfig0)
|
|
3447
|
+
|
|
3448
|
+
if (inSlot === true) {
|
|
3449
|
+
slotChildCounter -= 1
|
|
3450
|
+
}
|
|
3451
|
+
|
|
3452
|
+
return elms
|
|
3453
|
+
}
|
|
3454
|
+
`
|
|
3455
|
+
const expectedEffect1 = `
|
|
3456
|
+
function anonymous(component, elms, context, components, rootComponent, effect) {
|
|
3457
|
+
elms[0].set('w', component.size.w)
|
|
3458
|
+
}
|
|
3459
|
+
`
|
|
3460
|
+
|
|
3461
|
+
const expectedEffect2 = `
|
|
3462
|
+
function anonymous(component, elms, context, components, rootComponent, effect) {
|
|
3463
|
+
elms[0].set('h', component.size.h)
|
|
3464
|
+
}
|
|
3465
|
+
`
|
|
3466
|
+
|
|
3467
|
+
const actual = generator.call(scope, templateObject, true)
|
|
3468
|
+
|
|
3469
|
+
assert.equal(
|
|
3470
|
+
normalize(actual.render.toString()),
|
|
3471
|
+
normalize(expectedRender),
|
|
3472
|
+
'Generator should return a render function with the correct code'
|
|
3473
|
+
)
|
|
3474
|
+
|
|
3475
|
+
assert.ok(
|
|
3476
|
+
Array.isArray(actual.effects) && actual.effects.length === 2,
|
|
3477
|
+
'Generator should return an effects array with 2 item'
|
|
3478
|
+
)
|
|
3479
|
+
|
|
3480
|
+
assert.equal(
|
|
3481
|
+
normalize(actual.effects[0].toString()),
|
|
3482
|
+
normalize(expectedEffect1),
|
|
3483
|
+
'Generator should return an effect function for the reactive eWidth attribute'
|
|
3484
|
+
)
|
|
3485
|
+
|
|
3486
|
+
assert.equal(
|
|
3487
|
+
normalize(actual.effects[1].toString()),
|
|
3488
|
+
normalize(expectedEffect2),
|
|
3489
|
+
'Generator should return an effect function for the reactive eHeight attribute'
|
|
3490
|
+
)
|
|
3491
|
+
|
|
3492
|
+
assert.end()
|
|
3493
|
+
})
|
|
3494
|
+
|
|
3495
|
+
test('Generate code for a template with verification of attributes with Math calculations', (assert) => {
|
|
3496
|
+
const templateObject = {
|
|
3497
|
+
children: [
|
|
3498
|
+
{
|
|
3499
|
+
[Symbol.for('componentType')]: 'Element',
|
|
3500
|
+
x: '$position.x * 100',
|
|
3501
|
+
y: '$position.y + 100',
|
|
3502
|
+
':w': '$size.w * $correction ',
|
|
3503
|
+
':h': '$size.h + $borderY',
|
|
3504
|
+
},
|
|
3505
|
+
],
|
|
3506
|
+
}
|
|
3507
|
+
|
|
3508
|
+
const expectedRender = `
|
|
3509
|
+
function anonymous(parent, component, context, components, effect, getRaw, Log) {
|
|
3510
|
+
const elms = []
|
|
3511
|
+
let componentType
|
|
3512
|
+
const rootComponent = component
|
|
3513
|
+
let propData
|
|
3514
|
+
let slotComponent
|
|
3515
|
+
let inSlot = false
|
|
3516
|
+
let slotChildCounter = 0
|
|
3517
|
+
|
|
3518
|
+
function propInComponent(prop, kind = "dynamic") {
|
|
3519
|
+
const property = prop.includes('.') ? prop.split('.')[0] : prop
|
|
3520
|
+
if (kind === 'reactive' || prop.includes('.') === false) {
|
|
3521
|
+
if (property in component === false) {
|
|
3522
|
+
Log.warn('Property ' + property + ' was accessed during render but is not defined on instance')
|
|
3523
|
+
}
|
|
3524
|
+
} else {
|
|
3525
|
+
const nestedKeys = prop.split('.')
|
|
3526
|
+
let base = component
|
|
3527
|
+
for (let i = 0; i < nestedKeys.length; i++) {
|
|
3528
|
+
if (base[nestedKeys[i]] === undefined) {
|
|
3529
|
+
Log.warn('Property ' + nestedKeys.slice(0, i + 1).join('.') + ' was accessed during render but is not defined on instance')
|
|
3530
|
+
}
|
|
3531
|
+
base = base[nestedKeys[i]]
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
|
|
3536
|
+
const elementConfig0 = {}
|
|
3537
|
+
|
|
3538
|
+
elms[0] = this.element({ parent: parent || 'root' }, inSlot === true ? slotComponent : component)
|
|
3539
|
+
|
|
3540
|
+
propInComponent('position.x', 'dynamic')
|
|
3541
|
+
elementConfig0['x'] = component.position.x * 100
|
|
3542
|
+
propInComponent('position.y', 'dynamic')
|
|
3543
|
+
elementConfig0['y'] = component.position.y + 100
|
|
3544
|
+
propInComponent('size', 'reactive')
|
|
3545
|
+
propInComponent('correction', 'reactive')
|
|
3546
|
+
elementConfig0['w'] = component.size.w * component.correction
|
|
3547
|
+
propInComponent('size', 'reactive')
|
|
3548
|
+
propInComponent('borderY', 'reactive')
|
|
3549
|
+
elementConfig0['h'] = component.size.h + component.borderY
|
|
3550
|
+
|
|
3551
|
+
elms[0].populate(elementConfig0)
|
|
3552
|
+
|
|
3553
|
+
if (inSlot === true) {
|
|
3554
|
+
slotChildCounter -= 1
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
return elms
|
|
3558
|
+
}
|
|
3559
|
+
`
|
|
3560
|
+
const expectedEffect1 = `
|
|
3561
|
+
function anonymous(component, elms, context, components, rootComponent, effect) {
|
|
3562
|
+
elms[0].set('w', component.size.w * component.correction)
|
|
3563
|
+
}
|
|
3564
|
+
`
|
|
3565
|
+
|
|
3566
|
+
const expectedEffect2 = `
|
|
3567
|
+
function anonymous(component, elms, context, components, rootComponent, effect) {
|
|
3568
|
+
elms[0].set('h', component.size.h + component.borderY)
|
|
3569
|
+
}
|
|
3570
|
+
`
|
|
3571
|
+
|
|
3572
|
+
const actual = generator.call(scope, templateObject, true)
|
|
3573
|
+
|
|
3574
|
+
assert.equal(
|
|
3575
|
+
normalize(actual.render.toString()),
|
|
3576
|
+
normalize(expectedRender),
|
|
3577
|
+
'Generator should return a render function with the correct code'
|
|
3578
|
+
)
|
|
3579
|
+
|
|
3580
|
+
assert.ok(
|
|
3581
|
+
Array.isArray(actual.effects) && actual.effects.length === 2,
|
|
3582
|
+
'Generator should return an effects array with 2 item'
|
|
3583
|
+
)
|
|
3584
|
+
|
|
3585
|
+
assert.equal(
|
|
3586
|
+
normalize(actual.effects[0].toString()),
|
|
3587
|
+
normalize(expectedEffect1),
|
|
3588
|
+
'Generator should return an effect function for the reactive width attribute'
|
|
3589
|
+
)
|
|
3590
|
+
|
|
3591
|
+
assert.equal(
|
|
3592
|
+
normalize(actual.effects[1].toString()),
|
|
3593
|
+
normalize(expectedEffect2),
|
|
3594
|
+
'Generator should return an effect function for the reactive height attribute'
|
|
3595
|
+
)
|
|
3596
|
+
|
|
3597
|
+
assert.end()
|
|
3598
|
+
})
|