@lightningjs/blits 1.8.2 → 1.9.0
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/CHANGELOG.md +15 -1
- package/docs/_sidebar.md +1 -0
- package/docs/built-in/layout.md +76 -0
- package/docs/sidebar.json +4 -0
- package/index.d.ts +23 -23
- package/package.json +1 -1
- package/src/components/index.js +0 -2
- package/src/components/index.orig.js +0 -2
- package/src/engines/L3/element.js +51 -9
- package/src/lib/codegenerator/generator.js +5 -4
- package/src/lib/codegenerator/generator.test.js +633 -609
- package/src/components/Layout.js +0 -50
- package/src/components/Layout.orig.js +0 -34
|
@@ -84,6 +84,7 @@ test('Generate render and effect code for an empty template', (assert) => {
|
|
|
84
84
|
const elms = []
|
|
85
85
|
let componentType
|
|
86
86
|
const rootComponent = component
|
|
87
|
+
let propData
|
|
87
88
|
return elms
|
|
88
89
|
}
|
|
89
90
|
`
|
|
@@ -116,6 +117,7 @@ test('Generate render and effect code for a template with a single simple elemen
|
|
|
116
117
|
const elms = []
|
|
117
118
|
let componentType
|
|
118
119
|
const rootComponent = component
|
|
120
|
+
let propData
|
|
119
121
|
const elementConfig0 = {}
|
|
120
122
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
121
123
|
elms[0].populate(elementConfig0)
|
|
@@ -156,6 +158,7 @@ test('Generate code for a template with a simple element and a simple nested ele
|
|
|
156
158
|
const elms = []
|
|
157
159
|
let componentType
|
|
158
160
|
const rootComponent = component
|
|
161
|
+
let propData
|
|
159
162
|
const elementConfig0 = {}
|
|
160
163
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
161
164
|
elms[0].populate(elementConfig0)
|
|
@@ -197,6 +200,7 @@ test('Generate code for a template with a single element with attributes', (asse
|
|
|
197
200
|
const elms = []
|
|
198
201
|
let componentType
|
|
199
202
|
const rootComponent = component
|
|
203
|
+
let propData
|
|
200
204
|
const elementConfig0 = {}
|
|
201
205
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
202
206
|
|
|
@@ -237,6 +241,7 @@ test('Generate code for a template with a single element with attributes with a
|
|
|
237
241
|
const elms = []
|
|
238
242
|
let componentType
|
|
239
243
|
const rootComponent = component
|
|
244
|
+
let propData
|
|
240
245
|
const elementConfig0 = {}
|
|
241
246
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
242
247
|
elementConfig0['one'] = true
|
|
@@ -283,6 +288,7 @@ test('Generate code for a template with attributes and a nested element with att
|
|
|
283
288
|
const elms = []
|
|
284
289
|
let componentType
|
|
285
290
|
const rootComponent = component
|
|
291
|
+
let propData
|
|
286
292
|
const elementConfig0 = {}
|
|
287
293
|
|
|
288
294
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
@@ -347,6 +353,7 @@ test('Generate code for a template with attributes and 2 nested elements with at
|
|
|
347
353
|
const elms = []
|
|
348
354
|
let componentType
|
|
349
355
|
const rootComponent = component
|
|
356
|
+
let propData
|
|
350
357
|
const elementConfig0 = {}
|
|
351
358
|
|
|
352
359
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
@@ -432,6 +439,7 @@ test('Generate code for a template with attributes and deep nested elements with
|
|
|
432
439
|
const elms = []
|
|
433
440
|
let componentType
|
|
434
441
|
const rootComponent = component
|
|
442
|
+
let propData
|
|
435
443
|
const elementConfig0 = {}
|
|
436
444
|
|
|
437
445
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
@@ -512,6 +520,7 @@ test('Generate code for a template with simple dynamic attributes', (assert) =>
|
|
|
512
520
|
const elms = []
|
|
513
521
|
let componentType
|
|
514
522
|
const rootComponent = component
|
|
523
|
+
let propData
|
|
515
524
|
const elementConfig0 = {}
|
|
516
525
|
|
|
517
526
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
@@ -580,6 +589,7 @@ test('Generate code for a template with an attribute with a dash', (assert) => {
|
|
|
580
589
|
const elms = []
|
|
581
590
|
let componentType
|
|
582
591
|
const rootComponent = component
|
|
592
|
+
let propData
|
|
583
593
|
const elementConfig0 = {}
|
|
584
594
|
|
|
585
595
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
@@ -624,6 +634,7 @@ test('Generate code for a template with dynamic attributes with code to be evalu
|
|
|
624
634
|
const elms = []
|
|
625
635
|
let componentType
|
|
626
636
|
const rootComponent = component
|
|
637
|
+
let propData
|
|
627
638
|
const elementConfig0 = {}
|
|
628
639
|
|
|
629
640
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
@@ -701,6 +712,7 @@ test('Generate code for a template with attribute (object)', (assert) => {
|
|
|
701
712
|
const elms = []
|
|
702
713
|
let componentType
|
|
703
714
|
const rootComponent = component
|
|
715
|
+
let propData
|
|
704
716
|
const elementConfig0 = {}
|
|
705
717
|
|
|
706
718
|
elms[0] = this.element({parent: parent || 'root'}, component)
|
|
@@ -714,7 +726,6 @@ test('Generate code for a template with attribute (object)', (assert) => {
|
|
|
714
726
|
`
|
|
715
727
|
|
|
716
728
|
const actual = generator.call(scope, templateObject)
|
|
717
|
-
console.log(actual.render.toString())
|
|
718
729
|
assert.equal(
|
|
719
730
|
normalize(actual.render.toString()),
|
|
720
731
|
normalize(expectedRender),
|
|
@@ -745,6 +756,7 @@ test('Generate code for a template with dynamic attribute (object)', (assert) =>
|
|
|
745
756
|
const elms = []
|
|
746
757
|
let componentType
|
|
747
758
|
const rootComponent = component
|
|
759
|
+
let propData
|
|
748
760
|
const elementConfig0 = {}
|
|
749
761
|
|
|
750
762
|
elms[0] = this.element({parent: parent || 'root'}, component)
|
|
@@ -789,6 +801,7 @@ test('Generate code for a template with attribute (object) with mixed dynamic &
|
|
|
789
801
|
const elms = []
|
|
790
802
|
let componentType
|
|
791
803
|
const rootComponent = component
|
|
804
|
+
let propData
|
|
792
805
|
const elementConfig0 = {}
|
|
793
806
|
|
|
794
807
|
elms[0] = this.element({parent: parent || 'root'}, component)
|
|
@@ -833,6 +846,7 @@ test('Generate code for a template with @-listeners', (assert) => {
|
|
|
833
846
|
const elms = []
|
|
834
847
|
let componentType
|
|
835
848
|
const rootComponent = component
|
|
849
|
+
let propData
|
|
836
850
|
const elementConfig0 = {}
|
|
837
851
|
|
|
838
852
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
@@ -884,82 +898,96 @@ test('Generate code for a template with custom components', (assert) => {
|
|
|
884
898
|
|
|
885
899
|
const expectedRender = `
|
|
886
900
|
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
901
|
+
const elms = []
|
|
902
|
+
let componentType
|
|
903
|
+
const rootComponent = component
|
|
904
|
+
let propData
|
|
905
|
+
const elementConfig0 = {}
|
|
891
906
|
|
|
892
|
-
|
|
893
|
-
|
|
907
|
+
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
908
|
+
elms[0].populate(elementConfig0)
|
|
894
909
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
910
|
+
const cmp1 = (context.components && context.components['Poster']) || components['Poster']
|
|
911
|
+
parent = elms[0]
|
|
912
|
+
const elementConfig1 = {}
|
|
898
913
|
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
914
|
+
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
915
|
+
const skip1 = []
|
|
916
|
+
|
|
917
|
+
if (typeof cmp1 !== 'undefined') {
|
|
918
|
+
for (let key in cmp1.config.props) {
|
|
919
|
+
delete elementConfig1[cmp1.config.props[key]]
|
|
920
|
+
skip1.push(cmp1.config.props[key])
|
|
903
921
|
}
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
elms[1].populate(elementConfig1)
|
|
925
|
+
parent = elms[1]
|
|
926
|
+
|
|
927
|
+
const props2 = {}
|
|
928
|
+
componentType = props2['is'] || 'Poster'
|
|
929
|
+
let component2
|
|
930
|
+
|
|
931
|
+
if (typeof componentType === 'string') {
|
|
932
|
+
component2 = context.components && context.components[componentType] || components[componentType]
|
|
933
|
+
if (!component2) {
|
|
934
|
+
throw new Error('Component "Poster" not found')
|
|
935
|
+
}
|
|
936
|
+
} else if (typeof componentType === 'function' && componentType[Symbol.for('isComponent')] === true) {
|
|
937
|
+
component2 = componentType
|
|
938
|
+
}
|
|
919
939
|
|
|
920
|
-
|
|
921
|
-
|
|
940
|
+
elms[2] = component2.call(null, { props: props2 }, elms[1], component)
|
|
941
|
+
|
|
942
|
+
if (elms[2][Symbol.for('slots')][0]) {
|
|
922
943
|
parent = elms[2][Symbol.for('slots')][0]
|
|
923
944
|
component = elms[2]
|
|
924
|
-
|
|
945
|
+
} else {
|
|
925
946
|
parent = elms[2][Symbol.for('children')][0]
|
|
926
|
-
|
|
947
|
+
}
|
|
927
948
|
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
949
|
+
const cmp3 = (context.components && context.components['Poster']) || components['Poster']
|
|
950
|
+
parent = elms[0]
|
|
951
|
+
const elementConfig3 = {}
|
|
931
952
|
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
953
|
+
elms[3] = this.element({ parent: parent || 'root' }, component)
|
|
954
|
+
const skip3 = []
|
|
955
|
+
|
|
956
|
+
if (typeof cmp3 !== 'undefined') {
|
|
957
|
+
for (let key in cmp3.config.props) {
|
|
958
|
+
delete elementConfig3[cmp3.config.props[key]]
|
|
959
|
+
skip3.push(cmp3.config.props[key])
|
|
936
960
|
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
elms[3].populate(elementConfig3)
|
|
964
|
+
parent = elms[3]
|
|
965
|
+
|
|
966
|
+
const props4 = {}
|
|
967
|
+
componentType = props4['is'] || 'Poster'
|
|
968
|
+
let component4
|
|
969
|
+
|
|
970
|
+
if (typeof componentType === 'string') {
|
|
971
|
+
component4 = context.components && context.components[componentType] || components[componentType]
|
|
972
|
+
if (!component4) {
|
|
973
|
+
throw new Error('Component "Poster" not found')
|
|
950
974
|
}
|
|
975
|
+
} else if (typeof componentType === 'function' && componentType[Symbol.for('isComponent')] === true) {
|
|
976
|
+
component4 = componentType
|
|
977
|
+
}
|
|
951
978
|
|
|
952
|
-
|
|
979
|
+
elms[4] = component4.call(null, { props: props4 }, elms[3], component)
|
|
953
980
|
|
|
954
|
-
|
|
981
|
+
if (elms[4][Symbol.for('slots')][0]) {
|
|
955
982
|
parent = elms[4][Symbol.for('slots')][0]
|
|
956
983
|
component = elms[4]
|
|
957
|
-
|
|
984
|
+
} else {
|
|
958
985
|
parent = elms[4][Symbol.for('children')][0]
|
|
959
|
-
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
return elms
|
|
989
|
+
}
|
|
960
990
|
|
|
961
|
-
return elms
|
|
962
|
-
}
|
|
963
991
|
`
|
|
964
992
|
|
|
965
993
|
const actual = generator.call(scope, templateObject)
|
|
@@ -1002,85 +1030,76 @@ test('Generate code for a template with an unregistered custom component', (asse
|
|
|
1002
1030
|
|
|
1003
1031
|
const expectedRender = `
|
|
1004
1032
|
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1033
|
+
const elms = []
|
|
1034
|
+
let componentType
|
|
1035
|
+
const rootComponent = component
|
|
1036
|
+
let propData
|
|
1037
|
+
const elementConfig0 = {}
|
|
1038
|
+
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
1039
|
+
elms[0].populate(elementConfig0)
|
|
1040
|
+
const cmp1 = (context.components && context.components['Poster']) || components['Poster']
|
|
1041
|
+
parent = elms[0]
|
|
1042
|
+
const elementConfig1 = {}
|
|
1043
|
+
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
1044
|
+
const skip1 = []
|
|
1045
|
+
if (typeof cmp1 !== 'undefined') {
|
|
1046
|
+
for (let key in cmp1.config.props) {
|
|
1047
|
+
delete elementConfig1[cmp1.config.props[key]]
|
|
1048
|
+
skip1.push(cmp1.config.props[key])
|
|
1021
1049
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
elms[2] = component2.call(null, { props: props2 }, elms[1], component)
|
|
1040
|
-
|
|
1041
|
-
if(elms[2][Symbol.for('slots')][0]) {
|
|
1050
|
+
}
|
|
1051
|
+
elms[1].populate(elementConfig1)
|
|
1052
|
+
parent = elms[1]
|
|
1053
|
+
const props2 = {}
|
|
1054
|
+
componentType = props2['is'] || 'Poster'
|
|
1055
|
+
let component2
|
|
1056
|
+
if (typeof componentType === 'string') {
|
|
1057
|
+
component2 = context.components && context.components[componentType] || components[componentType]
|
|
1058
|
+
if (!component2) {
|
|
1059
|
+
throw new Error('Component "Poster" not found')
|
|
1060
|
+
}
|
|
1061
|
+
} else if (typeof componentType === 'function' && componentType[Symbol.for('isComponent')] === true) {
|
|
1062
|
+
component2 = componentType
|
|
1063
|
+
}
|
|
1064
|
+
elms[2] = component2.call(null, { props: props2 }, elms[1], component)
|
|
1065
|
+
if (elms[2][Symbol.for('slots')][0]) {
|
|
1042
1066
|
parent = elms[2][Symbol.for('slots')][0]
|
|
1043
1067
|
component = elms[2]
|
|
1044
|
-
|
|
1068
|
+
} else {
|
|
1045
1069
|
parent = elms[2][Symbol.for('children')][0]
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1070
|
+
}
|
|
1071
|
+
const cmp3 = (context.components && context.components['Poster2']) || components['Poster2']
|
|
1072
|
+
parent = elms[0]
|
|
1073
|
+
const elementConfig3 = {}
|
|
1074
|
+
elms[3] = this.element({ parent: parent || 'root' }, component)
|
|
1075
|
+
const skip3 = []
|
|
1076
|
+
if (typeof cmp3 !== 'undefined') {
|
|
1077
|
+
for (let key in cmp3.config.props) {
|
|
1078
|
+
delete elementConfig3[cmp3.config.props[key]]
|
|
1079
|
+
skip3.push(cmp3.config.props[key])
|
|
1056
1080
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
elms[4] = component4.call(null, { props: props4 }, elms[3], component)
|
|
1075
|
-
|
|
1076
|
-
if(elms[4][Symbol.for('slots')][0]) {
|
|
1081
|
+
}
|
|
1082
|
+
elms[3].populate(elementConfig3)
|
|
1083
|
+
parent = elms[3]
|
|
1084
|
+
const props4 = {}
|
|
1085
|
+
componentType = props4['is'] || 'Poster2'
|
|
1086
|
+
let component4
|
|
1087
|
+
if (typeof componentType === 'string') {
|
|
1088
|
+
component4 = context.components && context.components[componentType] || components[componentType]
|
|
1089
|
+
if (!component4) {
|
|
1090
|
+
throw new Error('Component "Poster2" not found')
|
|
1091
|
+
}
|
|
1092
|
+
} else if (typeof componentType === 'function' && componentType[Symbol.for('isComponent')] === true) {
|
|
1093
|
+
component4 = componentType
|
|
1094
|
+
}
|
|
1095
|
+
elms[4] = component4.call(null, { props: props4 }, elms[3], component)
|
|
1096
|
+
if (elms[4][Symbol.for('slots')][0]) {
|
|
1077
1097
|
parent = elms[4][Symbol.for('slots')][0]
|
|
1078
1098
|
component = elms[4]
|
|
1079
|
-
|
|
1099
|
+
} else {
|
|
1080
1100
|
parent = elms[4][Symbol.for('children')][0]
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
return elms
|
|
1101
|
+
}
|
|
1102
|
+
return elms
|
|
1084
1103
|
}
|
|
1085
1104
|
`
|
|
1086
1105
|
|
|
@@ -1127,88 +1146,82 @@ test('Generate code for a template with custom components with arguments', (asse
|
|
|
1127
1146
|
|
|
1128
1147
|
const expectedRender = `
|
|
1129
1148
|
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1149
|
+
const elms = []
|
|
1150
|
+
let componentType
|
|
1151
|
+
const rootComponent = component
|
|
1152
|
+
let propData
|
|
1153
|
+
const elementConfig0 = {}
|
|
1154
|
+
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
1155
|
+
elms[0].populate(elementConfig0)
|
|
1156
|
+
const cmp1 = (context.components && context.components['Poster']) || components['Poster']
|
|
1157
|
+
parent = elms[0]
|
|
1158
|
+
const elementConfig1 = {}
|
|
1159
|
+
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
1160
|
+
elementConfig1['x'] = 10
|
|
1161
|
+
const skip1 = []
|
|
1162
|
+
if (typeof cmp1 !== 'undefined') {
|
|
1163
|
+
for (let key in cmp1.config.props) {
|
|
1164
|
+
delete elementConfig1[cmp1.config.props[key]]
|
|
1165
|
+
skip1.push(cmp1.config.props[key])
|
|
1147
1166
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
if(elms[2][Symbol.for('slots')][0]) {
|
|
1167
|
+
}
|
|
1168
|
+
elms[1].populate(elementConfig1)
|
|
1169
|
+
parent = elms[1]
|
|
1170
|
+
const props2 = {}
|
|
1171
|
+
props2['x'] = 10
|
|
1172
|
+
componentType = props2['is'] || 'Poster'
|
|
1173
|
+
let component2
|
|
1174
|
+
if (typeof componentType === 'string') {
|
|
1175
|
+
component2 = context.components && context.components[componentType] || components[componentType]
|
|
1176
|
+
if (!component2) {
|
|
1177
|
+
throw new Error('Component "Poster" not found')
|
|
1178
|
+
}
|
|
1179
|
+
} else if (typeof componentType === 'function' && componentType[Symbol.for('isComponent')] === true) {
|
|
1180
|
+
component2 = componentType
|
|
1181
|
+
}
|
|
1182
|
+
elms[2] = component2.call(null, { props: props2 }, elms[1], component)
|
|
1183
|
+
if (elms[2][Symbol.for('slots')][0]) {
|
|
1166
1184
|
parent = elms[2][Symbol.for('slots')][0]
|
|
1167
1185
|
component = elms[2]
|
|
1168
|
-
|
|
1186
|
+
} else {
|
|
1169
1187
|
parent = elms[2][Symbol.for('children')][0]
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1188
|
+
}
|
|
1189
|
+
const cmp3 = (context.components && context.components['Poster']) || components['Poster']
|
|
1190
|
+
parent = elms[0]
|
|
1191
|
+
const elementConfig3 = {}
|
|
1192
|
+
elms[3] = this.element({ parent: parent || 'root' }, component)
|
|
1193
|
+
elementConfig3['x'] = 100
|
|
1194
|
+
elementConfig3['img'] = component.img
|
|
1195
|
+
const skip3 = []
|
|
1196
|
+
if (typeof cmp3 !== 'undefined') {
|
|
1197
|
+
for (let key in cmp3.config.props) {
|
|
1198
|
+
delete elementConfig3[cmp3.config.props[key]]
|
|
1199
|
+
skip3.push(cmp3.config.props[key])
|
|
1182
1200
|
}
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
elms[4] = component4.call(null, { props: props4 }, elms[3], component)
|
|
1203
|
-
|
|
1204
|
-
if(elms[4][Symbol.for('slots')][0]) {
|
|
1201
|
+
}
|
|
1202
|
+
elms[3].populate(elementConfig3)
|
|
1203
|
+
parent = elms[3]
|
|
1204
|
+
const props4 = {}
|
|
1205
|
+
props4['x'] = 100
|
|
1206
|
+
props4['img'] = component.img
|
|
1207
|
+
componentType = props4['is'] || 'Poster'
|
|
1208
|
+
let component4
|
|
1209
|
+
if (typeof componentType === 'string') {
|
|
1210
|
+
component4 = context.components && context.components[componentType] || components[componentType]
|
|
1211
|
+
if (!component4) {
|
|
1212
|
+
throw new Error('Component "Poster" not found')
|
|
1213
|
+
}
|
|
1214
|
+
} else if (typeof componentType === 'function' && componentType[Symbol.for('isComponent')] === true) {
|
|
1215
|
+
component4 = componentType
|
|
1216
|
+
}
|
|
1217
|
+
elms[4] = component4.call(null, { props: props4 }, elms[3], component)
|
|
1218
|
+
if (elms[4][Symbol.for('slots')][0]) {
|
|
1205
1219
|
parent = elms[4][Symbol.for('slots')][0]
|
|
1206
1220
|
component = elms[4]
|
|
1207
|
-
|
|
1221
|
+
} else {
|
|
1208
1222
|
parent = elms[4][Symbol.for('children')][0]
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
return elms
|
|
1223
|
+
}
|
|
1224
|
+
return elms
|
|
1212
1225
|
}
|
|
1213
1226
|
`
|
|
1214
1227
|
|
|
@@ -1255,99 +1268,100 @@ test('Generate code for a template with custom components with reactive props',
|
|
|
1255
1268
|
}
|
|
1256
1269
|
|
|
1257
1270
|
const expectedRender = `
|
|
1258
|
-
function anonymous(parent,
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
elms[1].populate(elementConfig1)
|
|
1280
|
-
parent = elms[1]
|
|
1281
|
-
|
|
1282
|
-
const props2 = {}
|
|
1283
|
-
props2['x'] = 10
|
|
1284
|
-
props2['img'] = component.image
|
|
1285
|
-
componentType = props2['is'] || 'Poster'
|
|
1286
|
-
let component2
|
|
1287
|
-
|
|
1288
|
-
if (typeof componentType === 'string') {
|
|
1289
|
-
component2 = context.components && context.components[componentType] || components[componentType]
|
|
1290
|
-
if (!component2) {
|
|
1291
|
-
throw new Error('Component "Poster" not found')
|
|
1292
|
-
}
|
|
1293
|
-
} else if (typeof componentType === 'function' && componentType.name === 'factory') {
|
|
1294
|
-
component2 = componentType
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
elms[2] = component2.call(null, { props: props2 }, elms[1], component)
|
|
1298
|
-
|
|
1299
|
-
if(elms[2][Symbol.for('slots')][0]) {
|
|
1300
|
-
parent = elms[2][Symbol.for('slots')][0]
|
|
1301
|
-
component = elms[2]
|
|
1302
|
-
} else {
|
|
1303
|
-
parent = elms[2][Symbol.for('children')][0]
|
|
1271
|
+
function anonymous(parent,component,context,components,effect,getRaw) {
|
|
1272
|
+
const elms = []
|
|
1273
|
+
let componentType
|
|
1274
|
+
const rootComponent = component
|
|
1275
|
+
let propData
|
|
1276
|
+
const elementConfig0 = {}
|
|
1277
|
+
elms[0] = this.element({parent: parent || 'root'}, component)
|
|
1278
|
+
elms[0].populate(elementConfig0)
|
|
1279
|
+
const cmp1 = (context.components && context.components['Poster']) || components['Poster']
|
|
1280
|
+
parent = elms[0]
|
|
1281
|
+
const elementConfig1 = {}
|
|
1282
|
+
elms[1] = this.element({parent: parent || 'root'}, component)
|
|
1283
|
+
elementConfig1['x'] = 10
|
|
1284
|
+
elementConfig1['img'] = component.image
|
|
1285
|
+
const skip1 = []
|
|
1286
|
+
if(typeof cmp1 !== 'undefined') {
|
|
1287
|
+
for(let key in cmp1.config.props) {
|
|
1288
|
+
delete elementConfig1[cmp1.config.props[key]]
|
|
1289
|
+
skip1.push(cmp1.config.props[key])
|
|
1304
1290
|
}
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1291
|
+
}
|
|
1292
|
+
elms[1].populate(elementConfig1)
|
|
1293
|
+
parent = elms[1]
|
|
1294
|
+
const props2 = {}
|
|
1295
|
+
props2['x'] = 10
|
|
1296
|
+
propData = component.image
|
|
1297
|
+
if (Array.isArray(propData) === true) {
|
|
1298
|
+
propData = getRaw(propData).slice(0)
|
|
1299
|
+
}
|
|
1300
|
+
props2['img'] = propData
|
|
1301
|
+
componentType = props2['is'] || 'Poster'
|
|
1302
|
+
let component2
|
|
1303
|
+
if(typeof componentType === 'string') {
|
|
1304
|
+
component2 = context.components && context.components[componentType] || components[componentType]
|
|
1305
|
+
if(!component2) {
|
|
1306
|
+
throw new Error('Component "Poster" not found')
|
|
1317
1307
|
}
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1308
|
+
} else if(typeof componentType === 'function' && componentType[Symbol.for('isComponent')] === true) {
|
|
1309
|
+
component2 = componentType
|
|
1310
|
+
}
|
|
1311
|
+
elms[2] = component2.call(null, {props: props2}, elms[1], component)
|
|
1312
|
+
if (elms[2][Symbol.for('slots')][0]) {
|
|
1313
|
+
parent = elms[2][Symbol.for('slots')][0]
|
|
1314
|
+
component = elms[2]
|
|
1315
|
+
} else {
|
|
1316
|
+
parent = elms[2][Symbol.for('children')][0]
|
|
1317
|
+
}
|
|
1318
|
+
const cmp3 = (context.components && context.components['Poster']) || components['Poster']
|
|
1319
|
+
parent = elms[0]
|
|
1320
|
+
const elementConfig3 = {}
|
|
1321
|
+
elms[3] = this.element({parent: parent || 'root'}, component)
|
|
1322
|
+
elementConfig3['x'] = 100
|
|
1323
|
+
elementConfig3['img'] = component.image
|
|
1324
|
+
const skip3 = []
|
|
1325
|
+
if(typeof cmp3 !== 'undefined') {
|
|
1326
|
+
for(let key in cmp3.config.props) {
|
|
1327
|
+
delete elementConfig3[cmp3.config.props[key]]
|
|
1328
|
+
skip3.push(cmp3.config.props[key])
|
|
1334
1329
|
}
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1330
|
+
}
|
|
1331
|
+
elms[3].populate(elementConfig3)
|
|
1332
|
+
parent = elms[3]
|
|
1333
|
+
const props4 = {}
|
|
1334
|
+
props4['x'] = 100
|
|
1335
|
+
propData = component.image
|
|
1336
|
+
if (Array.isArray(propData) === true) {
|
|
1337
|
+
propData = getRaw(propData).slice(0)
|
|
1338
|
+
}
|
|
1339
|
+
props4['img'] = propData
|
|
1340
|
+
componentType = props4['is'] || 'Poster'
|
|
1341
|
+
let component4
|
|
1342
|
+
if(typeof componentType === 'string') {
|
|
1343
|
+
component4 = context.components && context.components[componentType] || components[componentType]
|
|
1344
|
+
if(!component4) {
|
|
1345
|
+
throw new Error('Component "Poster" not found')
|
|
1342
1346
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1347
|
+
} else if(typeof componentType === 'function' && componentType[Symbol.for('isComponent')] === true) {
|
|
1348
|
+
component4 = componentType
|
|
1349
|
+
}
|
|
1350
|
+
elms[4] = component4.call(null, {props: props4}, elms[3], component)
|
|
1351
|
+
if (elms[4][Symbol.for('slots')][0]) {
|
|
1352
|
+
parent = elms[4][Symbol.for('slots')][0]
|
|
1353
|
+
component = elms[4]
|
|
1354
|
+
} else {
|
|
1355
|
+
parent = elms[4][Symbol.for('children')][0]
|
|
1356
|
+
}
|
|
1357
|
+
return elms
|
|
1345
1358
|
}
|
|
1346
1359
|
`
|
|
1347
1360
|
|
|
1348
1361
|
const expectedEffect1 = `
|
|
1349
|
-
|
|
1350
|
-
|
|
1362
|
+
function anonymous(component, elms, context, components, rootComponent, effect) {
|
|
1363
|
+
if (typeof skip1 === 'undefined' || skip1.indexOf('img') === -1)
|
|
1364
|
+
elms[1].set('img', component.image)
|
|
1351
1365
|
}
|
|
1352
1366
|
`
|
|
1353
1367
|
|
|
@@ -1358,9 +1372,10 @@ test('Generate code for a template with custom components with reactive props',
|
|
|
1358
1372
|
`
|
|
1359
1373
|
|
|
1360
1374
|
const expectedEffect3 = `
|
|
1361
|
-
function anonymous(component,elms,context,components,rootComponent,effect) {
|
|
1362
|
-
|
|
1363
|
-
|
|
1375
|
+
function anonymous(component, elms, context, components, rootComponent, effect) {
|
|
1376
|
+
if (typeof skip3 === 'undefined' || skip3.indexOf('img') === -1)
|
|
1377
|
+
elms[3].set('img', component.image)
|
|
1378
|
+
}
|
|
1364
1379
|
`
|
|
1365
1380
|
|
|
1366
1381
|
const expectedEffect4 = `
|
|
@@ -1413,9 +1428,9 @@ test('Generate code for a template with a transition attributes', (assert) => {
|
|
|
1413
1428
|
const templateObject = {
|
|
1414
1429
|
children: [
|
|
1415
1430
|
{
|
|
1431
|
+
':x': '{transition: $myX}',
|
|
1432
|
+
':y': '{transition: {value: $myY, duration: 600}}',
|
|
1416
1433
|
[Symbol.for('componentType')]: 'Element',
|
|
1417
|
-
x: '{transition: $myX}',
|
|
1418
|
-
y: '{transition: {v: $myY, d: 600, p: 100}}',
|
|
1419
1434
|
},
|
|
1420
1435
|
],
|
|
1421
1436
|
}
|
|
@@ -1425,17 +1440,16 @@ test('Generate code for a template with a transition attributes', (assert) => {
|
|
|
1425
1440
|
const elms = []
|
|
1426
1441
|
let componentType
|
|
1427
1442
|
const rootComponent = component
|
|
1443
|
+
let propData
|
|
1428
1444
|
const elementConfig0 = {}
|
|
1429
1445
|
|
|
1430
1446
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
1431
|
-
elementConfig0['x'] =
|
|
1432
|
-
elementConfig0['y'] =
|
|
1447
|
+
elementConfig0['x'] = {transition:component.myX}
|
|
1448
|
+
elementConfig0['y'] = {transition:{value:component.myY,duration:600}}
|
|
1433
1449
|
elms[0].populate(elementConfig0)
|
|
1434
|
-
|
|
1435
1450
|
return elms
|
|
1436
1451
|
}
|
|
1437
1452
|
`
|
|
1438
|
-
|
|
1439
1453
|
const actual = generator.call(scope, templateObject)
|
|
1440
1454
|
|
|
1441
1455
|
assert.equal(
|
|
@@ -1444,8 +1458,8 @@ test('Generate code for a template with a transition attributes', (assert) => {
|
|
|
1444
1458
|
'Generator should return a render function with the correct code'
|
|
1445
1459
|
)
|
|
1446
1460
|
assert.ok(
|
|
1447
|
-
Array.isArray(actual.effects) && actual.effects.length
|
|
1448
|
-
'Generator should return an empty effects array'
|
|
1461
|
+
Array.isArray(actual.effects) && actual.effects.length !== 0,
|
|
1462
|
+
'Generator should not return an empty effects array'
|
|
1449
1463
|
)
|
|
1450
1464
|
assert.end()
|
|
1451
1465
|
})
|
|
@@ -1482,64 +1496,59 @@ test('Generate code for a template with slot content', (assert) => {
|
|
|
1482
1496
|
|
|
1483
1497
|
const expectedRender = `
|
|
1484
1498
|
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1499
|
+
const elms = []
|
|
1500
|
+
let componentType
|
|
1501
|
+
const rootComponent = component
|
|
1502
|
+
let propData
|
|
1503
|
+
const elementConfig0 = {}
|
|
1504
|
+
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
1505
|
+
elms[0].populate(elementConfig0)
|
|
1506
|
+
const cmp1 = (context.components && context.components['Page']) || components['Page']
|
|
1507
|
+
parent = elms[0]
|
|
1508
|
+
const elementConfig1 = {}
|
|
1509
|
+
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
1510
|
+
elementConfig1['w'] = 1920
|
|
1511
|
+
elementConfig1['h'] = 1080
|
|
1512
|
+
const skip1 = []
|
|
1513
|
+
if (typeof cmp1 !== 'undefined') {
|
|
1514
|
+
for (let key in cmp1.config.props) {
|
|
1515
|
+
delete elementConfig1[cmp1.config.props[key]]
|
|
1516
|
+
skip1.push(cmp1.config.props[key])
|
|
1503
1517
|
}
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
elms[2] = component2.call(null, { props: props2 }, elms[1], component)
|
|
1523
|
-
if(elms[2][Symbol.for('slots')][0]) {
|
|
1518
|
+
}
|
|
1519
|
+
elms[1].populate(elementConfig1)
|
|
1520
|
+
parent = elms[1]
|
|
1521
|
+
const props2 = {}
|
|
1522
|
+
props2['w'] = 1920
|
|
1523
|
+
props2['h'] = 1080
|
|
1524
|
+
componentType = props2['is'] || 'Page'
|
|
1525
|
+
let component2
|
|
1526
|
+
if (typeof componentType === 'string') {
|
|
1527
|
+
component2 = context.components && context.components[componentType] || components[componentType]
|
|
1528
|
+
if (!component2) {
|
|
1529
|
+
throw new Error('Component "Page" not found')
|
|
1530
|
+
}
|
|
1531
|
+
} else if (typeof componentType === 'function' && componentType[Symbol.for('isComponent')] === true) {
|
|
1532
|
+
component2 = componentType
|
|
1533
|
+
}
|
|
1534
|
+
elms[2] = component2.call(null, { props: props2 }, elms[1], component)
|
|
1535
|
+
if (elms[2][Symbol.for('slots')][0]) {
|
|
1524
1536
|
parent = elms[2][Symbol.for('slots')][0]
|
|
1525
1537
|
component = elms[2]
|
|
1526
|
-
|
|
1538
|
+
} else {
|
|
1527
1539
|
parent = elms[2][Symbol.for('children')][0]
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
elms[4].populate(elementConfig4)
|
|
1541
|
-
|
|
1542
|
-
return elms
|
|
1540
|
+
}
|
|
1541
|
+
const elementConfig3 = {}
|
|
1542
|
+
elms[3] = this.element({ parent: parent || 'root' }, component)
|
|
1543
|
+
elms[3].populate(elementConfig3)
|
|
1544
|
+
parent = elms[3]
|
|
1545
|
+
const elementConfig4 = {}
|
|
1546
|
+
elms[4] = this.element({ parent: parent || 'root' }, component)
|
|
1547
|
+
elementConfig4['x'] = 100
|
|
1548
|
+
elementConfig4['y'] = component.y
|
|
1549
|
+
elementConfig4['rotation'] = component.rotate
|
|
1550
|
+
elms[4].populate(elementConfig4)
|
|
1551
|
+
return elms
|
|
1543
1552
|
}
|
|
1544
1553
|
`
|
|
1545
1554
|
|
|
@@ -1603,67 +1612,60 @@ test('Generate code for a template with slot content, using a named slot', (asse
|
|
|
1603
1612
|
|
|
1604
1613
|
const expectedRender = `
|
|
1605
1614
|
function anonymous(parent, component, context, components, effect, getRaw) {
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1615
|
+
const elms = []
|
|
1616
|
+
let componentType
|
|
1617
|
+
const rootComponent = component
|
|
1618
|
+
let propData
|
|
1619
|
+
const elementConfig0 = {}
|
|
1620
|
+
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
1621
|
+
elms[0].populate(elementConfig0)
|
|
1622
|
+
const cmp1 = (context.components && context.components['Page']) || components['Page']
|
|
1623
|
+
parent = elms[0]
|
|
1624
|
+
const elementConfig1 = {}
|
|
1625
|
+
elms[1] = this.element({ parent: parent || 'root' }, component)
|
|
1626
|
+
elementConfig1['w'] = 1920
|
|
1627
|
+
elementConfig1['h'] = 1080
|
|
1628
|
+
const skip1 = []
|
|
1629
|
+
if (typeof cmp1 !== 'undefined') {
|
|
1630
|
+
for (let key in cmp1.config.props) {
|
|
1631
|
+
delete elementConfig1[cmp1.config.props[key]]
|
|
1632
|
+
skip1.push(cmp1.config.props[key])
|
|
1624
1633
|
}
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
}
|
|
1644
|
-
|
|
1645
|
-
elms[2] = component2.call(null, { props: props2 }, elms[1], component)
|
|
1646
|
-
if(elms[2][Symbol.for('slots')][0]) {
|
|
1634
|
+
}
|
|
1635
|
+
elms[1].populate(elementConfig1)
|
|
1636
|
+
parent = elms[1]
|
|
1637
|
+
const props2 = {}
|
|
1638
|
+
props2['w'] = 1920
|
|
1639
|
+
props2['h'] = 1080
|
|
1640
|
+
componentType = props2['is'] || 'Page'
|
|
1641
|
+
let component2
|
|
1642
|
+
if (typeof componentType === 'string') {
|
|
1643
|
+
component2 = context.components && context.components[componentType] || components[componentType]
|
|
1644
|
+
if (!component2) {
|
|
1645
|
+
throw new Error('Component "Page" not found')
|
|
1646
|
+
}
|
|
1647
|
+
} else if (typeof componentType === 'function' && componentType[Symbol.for('isComponent')] === true) {
|
|
1648
|
+
component2 = componentType
|
|
1649
|
+
}
|
|
1650
|
+
elms[2] = component2.call(null, { props: props2 }, elms[1], component)
|
|
1651
|
+
if (elms[2][Symbol.for('slots')][0]) {
|
|
1647
1652
|
parent = elms[2][Symbol.for('slots')][0]
|
|
1648
1653
|
component = elms[2]
|
|
1649
|
-
|
|
1654
|
+
} else {
|
|
1650
1655
|
parent = elms[2][Symbol.for('children')][0]
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
elms[4].populate(elementConfig4)
|
|
1665
|
-
|
|
1666
|
-
return elms
|
|
1656
|
+
}
|
|
1657
|
+
const elementConfig3 = {}
|
|
1658
|
+
elms[3] = this.element({ parent: parent || 'root' }, component)
|
|
1659
|
+
elms[3].populate(elementConfig3)
|
|
1660
|
+
parent = elms[3]
|
|
1661
|
+
const elementConfig4 = {}
|
|
1662
|
+
elms[4] = this.element({ parent: parent || 'root' }, component)
|
|
1663
|
+
elementConfig4['x'] = 100
|
|
1664
|
+
elementConfig4['y'] = component.y
|
|
1665
|
+
elementConfig4['parent'] = component[Symbol.for('slots')].filter(slot => slot.ref === 'mySlot').shift() || parent
|
|
1666
|
+
elementConfig4['slot'] = "mySlot"
|
|
1667
|
+
elms[4].populate(elementConfig4)
|
|
1668
|
+
return elms
|
|
1667
1669
|
}
|
|
1668
1670
|
`
|
|
1669
1671
|
|
|
@@ -1711,6 +1713,7 @@ test('Generate code for a template with a slot', (assert) => {
|
|
|
1711
1713
|
const elms = []
|
|
1712
1714
|
let componentType
|
|
1713
1715
|
const rootComponent = component
|
|
1716
|
+
let propData
|
|
1714
1717
|
const elementConfig0 = {}
|
|
1715
1718
|
|
|
1716
1719
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
@@ -1771,6 +1774,7 @@ test('Generate code for a template with inline Text', (assert) => {
|
|
|
1771
1774
|
const elms = []
|
|
1772
1775
|
let componentType
|
|
1773
1776
|
const rootComponent = component
|
|
1777
|
+
let propData
|
|
1774
1778
|
const elementConfig0 = {}
|
|
1775
1779
|
|
|
1776
1780
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
@@ -1821,6 +1825,7 @@ test('Generate code for a template with inline dynamic Text', (assert) => {
|
|
|
1821
1825
|
const elms = []
|
|
1822
1826
|
let componentType
|
|
1823
1827
|
const rootComponent = component
|
|
1828
|
+
let propData
|
|
1824
1829
|
const elementConfig0 = {}
|
|
1825
1830
|
|
|
1826
1831
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
@@ -1871,6 +1876,7 @@ test('Generate code for a template with inline dynamic Text embedded in static t
|
|
|
1871
1876
|
const elms = []
|
|
1872
1877
|
let componentType
|
|
1873
1878
|
const rootComponent = component
|
|
1879
|
+
let propData
|
|
1874
1880
|
const elementConfig0 = {}
|
|
1875
1881
|
|
|
1876
1882
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
@@ -1926,6 +1932,7 @@ test('Generate code for a template with a single element with attributes with pe
|
|
|
1926
1932
|
const elms = []
|
|
1927
1933
|
let componentType
|
|
1928
1934
|
const rootComponent = component
|
|
1935
|
+
let propData
|
|
1929
1936
|
const elementConfig0 = {}
|
|
1930
1937
|
|
|
1931
1938
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
@@ -1980,50 +1987,53 @@ test('Generate code for a template with a simple for-loop on an Element', (asser
|
|
|
1980
1987
|
const elms = []
|
|
1981
1988
|
let componentType
|
|
1982
1989
|
const rootComponent = component
|
|
1990
|
+
let propData
|
|
1983
1991
|
const elementConfig0 = {}
|
|
1984
1992
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
1985
1993
|
elms[0].populate(elementConfig0)
|
|
1986
1994
|
parent = elms[0]
|
|
1987
1995
|
const created1 = []
|
|
1988
1996
|
const forloop1 = (collection = [], elms, created) => {
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
delete elms[1][key]
|
|
1997
|
-
}
|
|
1998
|
-
}
|
|
1999
|
-
created.length = 0
|
|
2000
|
-
const length = collection.length
|
|
2001
|
-
for (let __index = 0; __index < length; __index++) {
|
|
2002
|
-
const scope = Object.create(component)
|
|
2003
|
-
parent = elms[0]
|
|
2004
|
-
scope['index'] = __index
|
|
2005
|
-
scope['item'] = rawCollection[__index]
|
|
2006
|
-
scope['key'] = __index
|
|
2007
|
-
created.push(scope.key)
|
|
2008
|
-
parent = elms[0]
|
|
2009
|
-
if (elms[1] === undefined) {
|
|
2010
|
-
elms[1] = {}
|
|
2011
|
-
}
|
|
2012
|
-
const elementConfig1 = {}
|
|
2013
|
-
if (!elms[1][scope.key]) {
|
|
2014
|
-
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
1997
|
+
const rawCollection = getRaw(collection)
|
|
1998
|
+
const keys = new Set()
|
|
1999
|
+
let l = rawCollection.length
|
|
2000
|
+
while (l--) {
|
|
2001
|
+
const item = rawCollection[l]
|
|
2002
|
+
const index = l
|
|
2003
|
+
keys.add('' + l)
|
|
2015
2004
|
}
|
|
2016
|
-
|
|
2017
|
-
|
|
2005
|
+
let i = created.length
|
|
2006
|
+
while (i--) {
|
|
2007
|
+
if (keys.has(created[i]) === false) {
|
|
2008
|
+
const key = created[i]
|
|
2009
|
+
elms[1][key] && elms[1][key].destroy()
|
|
2010
|
+
delete elms[1][key]
|
|
2011
|
+
}
|
|
2018
2012
|
}
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2013
|
+
created.length = 0
|
|
2014
|
+
const length = rawCollection.length
|
|
2015
|
+
for (let __index = 0; __index < length; __index++) {
|
|
2016
|
+
const scope = Object.create(component)
|
|
2017
|
+
parent = elms[0]
|
|
2018
|
+
scope['index'] = __index
|
|
2019
|
+
scope['item'] = rawCollection[__index]
|
|
2020
|
+
scope['key'] = '' + __index
|
|
2021
|
+
created.push(scope.key)
|
|
2022
|
+
parent = elms[0]
|
|
2023
|
+
if (elms[1] === undefined) {
|
|
2024
|
+
elms[1] = {}
|
|
2025
|
+
}
|
|
2026
|
+
const elementConfig1 = {}
|
|
2027
|
+
if (elms[1][scope.key] === undefined) {
|
|
2028
|
+
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
2029
|
+
}
|
|
2030
|
+
if (elms[1][scope.key].nodeId === undefined) {
|
|
2031
|
+
elms[1][scope.key].populate(elementConfig1)
|
|
2032
|
+
}
|
|
2022
2033
|
}
|
|
2023
|
-
}
|
|
2024
2034
|
}
|
|
2025
2035
|
effect(() => {
|
|
2026
|
-
|
|
2036
|
+
forloop1(component.items, elms, created1)
|
|
2027
2037
|
}, 'items')
|
|
2028
2038
|
return elms
|
|
2029
2039
|
}
|
|
@@ -2065,50 +2075,53 @@ test('Generate code for a template with a simple for-loop on an Element with a c
|
|
|
2065
2075
|
const elms = []
|
|
2066
2076
|
let componentType
|
|
2067
2077
|
const rootComponent = component
|
|
2078
|
+
let propData
|
|
2068
2079
|
const elementConfig0 = {}
|
|
2069
2080
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2070
2081
|
elms[0].populate(elementConfig0)
|
|
2071
2082
|
parent = elms[0]
|
|
2072
2083
|
const created1 = []
|
|
2073
2084
|
const forloop1 = (collection = [], elms, created) => {
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
delete elms[1][key]
|
|
2085
|
+
const rawCollection = getRaw(collection)
|
|
2086
|
+
const keys = new Set()
|
|
2087
|
+
let l = rawCollection.length
|
|
2088
|
+
while (l--) {
|
|
2089
|
+
const item = rawCollection[l]
|
|
2090
|
+
const customIndex = l
|
|
2091
|
+
keys.add('' + l)
|
|
2082
2092
|
}
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
scope['item'] = rawCollection[__index]
|
|
2091
|
-
scope['key'] = __index
|
|
2092
|
-
created.push(scope.key)
|
|
2093
|
-
parent = elms[0]
|
|
2094
|
-
if (elms[1] === undefined) {
|
|
2095
|
-
elms[1] = {}
|
|
2096
|
-
}
|
|
2097
|
-
const elementConfig1 = {}
|
|
2098
|
-
if (!elms[1][scope.key]) {
|
|
2099
|
-
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
2100
|
-
}
|
|
2101
|
-
if (!elms[1][scope.key].nodeId) {
|
|
2102
|
-
elms[1][scope.key].populate(elementConfig1)
|
|
2093
|
+
let i = created.length
|
|
2094
|
+
while (i--) {
|
|
2095
|
+
if (keys.has(created[i]) === false) {
|
|
2096
|
+
const key = created[i]
|
|
2097
|
+
elms[1][key] && elms[1][key].destroy()
|
|
2098
|
+
delete elms[1][key]
|
|
2099
|
+
}
|
|
2103
2100
|
}
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2101
|
+
created.length = 0
|
|
2102
|
+
const length = rawCollection.length
|
|
2103
|
+
for (let __index = 0; __index < length; __index++) {
|
|
2104
|
+
const scope = Object.create(component)
|
|
2105
|
+
parent = elms[0]
|
|
2106
|
+
scope['customIndex'] = __index
|
|
2107
|
+
scope['item'] = rawCollection[__index]
|
|
2108
|
+
scope['key'] = '' + __index
|
|
2109
|
+
created.push(scope.key)
|
|
2110
|
+
parent = elms[0]
|
|
2111
|
+
if (elms[1] === undefined) {
|
|
2112
|
+
elms[1] = {}
|
|
2113
|
+
}
|
|
2114
|
+
const elementConfig1 = {}
|
|
2115
|
+
if (elms[1][scope.key] === undefined) {
|
|
2116
|
+
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
2117
|
+
}
|
|
2118
|
+
if (elms[1][scope.key].nodeId === undefined) {
|
|
2119
|
+
elms[1][scope.key].populate(elementConfig1)
|
|
2120
|
+
}
|
|
2107
2121
|
}
|
|
2108
|
-
}
|
|
2109
2122
|
}
|
|
2110
2123
|
effect(() => {
|
|
2111
|
-
|
|
2124
|
+
forloop1(component.items, elms, created1)
|
|
2112
2125
|
}, 'items')
|
|
2113
2126
|
return elms
|
|
2114
2127
|
}
|
|
@@ -2151,50 +2164,53 @@ test('Generate code for a template with a simple for-loop on an Element with a k
|
|
|
2151
2164
|
const elms = []
|
|
2152
2165
|
let componentType
|
|
2153
2166
|
const rootComponent = component
|
|
2167
|
+
let propData
|
|
2154
2168
|
const elementConfig0 = {}
|
|
2155
2169
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2156
2170
|
elms[0].populate(elementConfig0)
|
|
2157
2171
|
parent = elms[0]
|
|
2158
2172
|
const created1 = []
|
|
2159
2173
|
const forloop1 = (collection = [], elms, created) => {
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
delete elms[1][key]
|
|
2168
|
-
}
|
|
2169
|
-
}
|
|
2170
|
-
created.length = 0
|
|
2171
|
-
const length = collection.length
|
|
2172
|
-
for (let __index = 0; __index < length; __index++) {
|
|
2173
|
-
const scope = Object.create(component)
|
|
2174
|
-
parent = elms[0]
|
|
2175
|
-
scope['index'] = __index
|
|
2176
|
-
scope['item'] = rawCollection[__index]
|
|
2177
|
-
scope['key'] = scope.item.id
|
|
2178
|
-
created.push(scope.key)
|
|
2179
|
-
parent = elms[0]
|
|
2180
|
-
if (elms[1] === undefined) {
|
|
2181
|
-
elms[1] = {}
|
|
2182
|
-
}
|
|
2183
|
-
const elementConfig1 = {}
|
|
2184
|
-
if (!elms[1][scope.key]) {
|
|
2185
|
-
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
2174
|
+
const rawCollection = getRaw(collection)
|
|
2175
|
+
const keys = new Set()
|
|
2176
|
+
let l = rawCollection.length
|
|
2177
|
+
while (l--) {
|
|
2178
|
+
const item = rawCollection[l]
|
|
2179
|
+
const index = l
|
|
2180
|
+
keys.add('' + item.id)
|
|
2186
2181
|
}
|
|
2187
|
-
|
|
2188
|
-
|
|
2182
|
+
let i = created.length
|
|
2183
|
+
while (i--) {
|
|
2184
|
+
if (keys.has(created[i]) === false) {
|
|
2185
|
+
const key = created[i]
|
|
2186
|
+
elms[1][key] && elms[1][key].destroy()
|
|
2187
|
+
delete elms[1][key]
|
|
2188
|
+
}
|
|
2189
2189
|
}
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2190
|
+
created.length = 0
|
|
2191
|
+
const length = rawCollection.length
|
|
2192
|
+
for (let __index = 0; __index < length; __index++) {
|
|
2193
|
+
const scope = Object.create(component)
|
|
2194
|
+
parent = elms[0]
|
|
2195
|
+
scope['index'] = __index
|
|
2196
|
+
scope['item'] = rawCollection[__index]
|
|
2197
|
+
scope['key'] = '' + scope.item.id
|
|
2198
|
+
created.push(scope.key)
|
|
2199
|
+
parent = elms[0]
|
|
2200
|
+
if (elms[1] === undefined) {
|
|
2201
|
+
elms[1] = {}
|
|
2202
|
+
}
|
|
2203
|
+
const elementConfig1 = {}
|
|
2204
|
+
if (elms[1][scope.key] === undefined) {
|
|
2205
|
+
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
2206
|
+
}
|
|
2207
|
+
if (elms[1][scope.key].nodeId === undefined) {
|
|
2208
|
+
elms[1][scope.key].populate(elementConfig1)
|
|
2209
|
+
}
|
|
2193
2210
|
}
|
|
2194
|
-
}
|
|
2195
2211
|
}
|
|
2196
2212
|
effect(() => {
|
|
2197
|
-
|
|
2213
|
+
forloop1(component.items, elms, created1)
|
|
2198
2214
|
}, 'items')
|
|
2199
2215
|
return elms
|
|
2200
2216
|
}
|
|
@@ -2237,82 +2253,86 @@ test('Generate code for a template with a simple for-loop on a Component with a
|
|
|
2237
2253
|
const elms = []
|
|
2238
2254
|
let componentType
|
|
2239
2255
|
const rootComponent = component
|
|
2256
|
+
let propData
|
|
2240
2257
|
const elementConfig0 = {}
|
|
2241
2258
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2242
2259
|
elms[0].populate(elementConfig0)
|
|
2243
2260
|
parent = elms[0]
|
|
2244
2261
|
const created1 = []
|
|
2245
2262
|
const forloop1 = (collection = [], elms, created) => {
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
delete elms[1][key]
|
|
2254
|
-
elms[2][key] && elms[2][key].destroy()
|
|
2255
|
-
delete elms[2][key]
|
|
2263
|
+
const rawCollection = getRaw(collection)
|
|
2264
|
+
const keys = new Set()
|
|
2265
|
+
let l = rawCollection.length
|
|
2266
|
+
while (l--) {
|
|
2267
|
+
const item = rawCollection[l]
|
|
2268
|
+
const myIndex = l
|
|
2269
|
+
keys.add('' + item.id)
|
|
2256
2270
|
}
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
scope['key'] = item.id
|
|
2266
|
-
created.push(scope.key)
|
|
2267
|
-
const cmp1 = (context.components && context.components['ListItem']) || components['ListItem']
|
|
2268
|
-
if (elms[1] === undefined) {
|
|
2269
|
-
elms[1] = {}
|
|
2270
|
-
}
|
|
2271
|
-
const elementConfig1 = {}
|
|
2272
|
-
if (!elms[1][scope.key]) {
|
|
2273
|
-
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
2274
|
-
}
|
|
2275
|
-
if (typeof cmp1 !== 'undefined') {
|
|
2276
|
-
for (let key in cmp1.config.props) {
|
|
2277
|
-
delete elementConfig1[cmp1.config.props[key]]
|
|
2278
|
-
}
|
|
2279
|
-
}
|
|
2280
|
-
if (!elms[1][scope.key].nodeId) {
|
|
2281
|
-
elms[1][scope.key].populate(elementConfig1)
|
|
2282
|
-
}
|
|
2283
|
-
if (elms[2] === undefined) {
|
|
2284
|
-
elms[2] = {}
|
|
2285
|
-
}
|
|
2286
|
-
parent = elms[1][scope.key]
|
|
2287
|
-
const props2 = {}
|
|
2288
|
-
if (!elms[2][scope.key]) {
|
|
2289
|
-
componentType = props2['is'] || 'ListItem'
|
|
2290
|
-
let component2
|
|
2291
|
-
if (typeof componentType === 'string') {
|
|
2292
|
-
component2 =
|
|
2293
|
-
context.components && context.components[componentType] || components[componentType]
|
|
2294
|
-
if (!component2) {
|
|
2295
|
-
throw new Error('Component "ListItem" not found')
|
|
2271
|
+
let i = created.length
|
|
2272
|
+
while (i--) {
|
|
2273
|
+
if (keys.has(created[i]) === false) {
|
|
2274
|
+
const key = created[i]
|
|
2275
|
+
elms[1][key] && elms[1][key].destroy()
|
|
2276
|
+
delete elms[1][key]
|
|
2277
|
+
elms[2][key] && elms[2][key].destroy()
|
|
2278
|
+
delete elms[2][key]
|
|
2296
2279
|
}
|
|
2297
|
-
} else if (typeof componentType === 'function' && componentType.name === 'factory') {
|
|
2298
|
-
component2 = componentType
|
|
2299
|
-
}
|
|
2300
|
-
elms[2][scope.key] = component2.call(null, { props: props2 }, elms[1][scope.key], component)
|
|
2301
|
-
if (elms[2][scope.key][Symbol.for('slots')][0]) {
|
|
2302
|
-
parent = elms[2][scope.key][Symbol.for('slots')][0]
|
|
2303
|
-
component = elms[2][scope.key]
|
|
2304
|
-
} else {
|
|
2305
|
-
parent = elms[2][scope.key][Symbol.for('children')][0]
|
|
2306
|
-
}
|
|
2307
2280
|
}
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2281
|
+
created.length = 0
|
|
2282
|
+
const length = rawCollection.length
|
|
2283
|
+
for (let __index = 0; __index < length; __index++) {
|
|
2284
|
+
const scope = Object.create(component)
|
|
2285
|
+
parent = elms[0]
|
|
2286
|
+
scope['myIndex'] = __index
|
|
2287
|
+
scope['item'] = rawCollection[__index]
|
|
2288
|
+
scope['key'] = '' + item.id
|
|
2289
|
+
created.push(scope.key)
|
|
2290
|
+
const cmp1 = (context.components && context.components['ListItem']) || components['ListItem']
|
|
2291
|
+
if (elms[1] === undefined) {
|
|
2292
|
+
elms[1] = {}
|
|
2293
|
+
}
|
|
2294
|
+
const elementConfig1 = {}
|
|
2295
|
+
if (elms[1][scope.key] === undefined) {
|
|
2296
|
+
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
2297
|
+
}
|
|
2298
|
+
const skip1 = []
|
|
2299
|
+
if (typeof cmp1 !== 'undefined') {
|
|
2300
|
+
for (let key in cmp1.config.props) {
|
|
2301
|
+
delete elementConfig1[cmp1.config.props[key]]
|
|
2302
|
+
skip1.push(cmp1.config.props[key])
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
if (elms[1][scope.key].nodeId === undefined) {
|
|
2306
|
+
elms[1][scope.key].populate(elementConfig1)
|
|
2307
|
+
}
|
|
2308
|
+
if (elms[2] === undefined) {
|
|
2309
|
+
elms[2] = {}
|
|
2310
|
+
}
|
|
2311
|
+
parent = elms[1][scope.key]
|
|
2312
|
+
const props2 = {}
|
|
2313
|
+
if (elms[2][scope.key] === undefined) {
|
|
2314
|
+
componentType = props2['is'] || 'ListItem'
|
|
2315
|
+
let component2
|
|
2316
|
+
if (typeof componentType === 'string') {
|
|
2317
|
+
component2 = context.components && context.components[componentType] || components[componentType]
|
|
2318
|
+
if (!component2) {
|
|
2319
|
+
throw new Error('Component "ListItem" not found')
|
|
2320
|
+
}
|
|
2321
|
+
} else if (typeof componentType === 'function' && componentType[Symbol.for('isComponent')] === true) {
|
|
2322
|
+
component2 = componentType
|
|
2323
|
+
}
|
|
2324
|
+
elms[2][scope.key] = component2.call(null, { props: props2 }, elms[1][scope.key], component)
|
|
2325
|
+
if (elms[2][scope.key][Symbol.for('slots')][0]) {
|
|
2326
|
+
parent = elms[2][scope.key][Symbol.for('slots')][0]
|
|
2327
|
+
component = elms[2][scope.key]
|
|
2328
|
+
} else {
|
|
2329
|
+
parent = elms[2][scope.key][Symbol.for('children')][0]
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2311
2332
|
}
|
|
2312
|
-
}
|
|
2313
2333
|
}
|
|
2314
2334
|
effect(() => {
|
|
2315
|
-
|
|
2335
|
+
forloop1(component.items, elms, created1)
|
|
2316
2336
|
}, 'items')
|
|
2317
2337
|
return elms
|
|
2318
2338
|
}
|
|
@@ -2356,52 +2376,55 @@ test('Generate code for a template with a simple for-loop on an Element with an
|
|
|
2356
2376
|
const elms = []
|
|
2357
2377
|
let componentType
|
|
2358
2378
|
const rootComponent = component
|
|
2379
|
+
let propData
|
|
2359
2380
|
const elementConfig0 = {}
|
|
2360
2381
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|
|
2361
2382
|
elms[0].populate(elementConfig0)
|
|
2362
2383
|
parent = elms[0]
|
|
2363
2384
|
const created1 = []
|
|
2364
2385
|
const forloop1 = (collection = [], elms, created) => {
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
delete elms[1][key]
|
|
2373
|
-
}
|
|
2374
|
-
}
|
|
2375
|
-
created.length = 0
|
|
2376
|
-
const length = collection.length
|
|
2377
|
-
for (let __index = 0; __index < length; __index++) {
|
|
2378
|
-
const scope = Object.create(component)
|
|
2379
|
-
parent = elms[0]
|
|
2380
|
-
scope['index'] = __index
|
|
2381
|
-
scope['item'] = rawCollection[__index]
|
|
2382
|
-
scope['key'] = item.id
|
|
2383
|
-
scope['__ref'] = 'myref' + __index
|
|
2384
|
-
created.push(scope.key)
|
|
2385
|
-
parent = elms[0]
|
|
2386
|
-
if (elms[1] === undefined) {
|
|
2387
|
-
elms[1] = {}
|
|
2388
|
-
}
|
|
2389
|
-
const elementConfig1 = {}
|
|
2390
|
-
if (!elms[1][scope.key]) {
|
|
2391
|
-
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
2386
|
+
const rawCollection = getRaw(collection)
|
|
2387
|
+
const keys = new Set()
|
|
2388
|
+
let l = rawCollection.length
|
|
2389
|
+
while (l--) {
|
|
2390
|
+
const item = rawCollection[l]
|
|
2391
|
+
const index = l
|
|
2392
|
+
keys.add('' + item.id)
|
|
2392
2393
|
}
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2394
|
+
let i = created.length
|
|
2395
|
+
while (i--) {
|
|
2396
|
+
if (keys.has(created[i]) === false) {
|
|
2397
|
+
const key = created[i]
|
|
2398
|
+
elms[1][key] && elms[1][key].destroy()
|
|
2399
|
+
delete elms[1][key]
|
|
2400
|
+
}
|
|
2396
2401
|
}
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2402
|
+
created.length = 0
|
|
2403
|
+
const length = rawCollection.length
|
|
2404
|
+
for (let __index = 0; __index < length; __index++) {
|
|
2405
|
+
const scope = Object.create(component)
|
|
2406
|
+
parent = elms[0]
|
|
2407
|
+
scope['index'] = __index
|
|
2408
|
+
scope['item'] = rawCollection[__index]
|
|
2409
|
+
scope['key'] = '' + item.id
|
|
2410
|
+
scope['__ref'] = 'myref' + __index
|
|
2411
|
+
created.push(scope.key)
|
|
2412
|
+
parent = elms[0]
|
|
2413
|
+
if (elms[1] === undefined) {
|
|
2414
|
+
elms[1] = {}
|
|
2415
|
+
}
|
|
2416
|
+
const elementConfig1 = {}
|
|
2417
|
+
if (elms[1][scope.key] === undefined) {
|
|
2418
|
+
elms[1][scope.key] = this.element({ parent: parent || 'root' }, component)
|
|
2419
|
+
}
|
|
2420
|
+
elementConfig1['ref'] = scope.__ref
|
|
2421
|
+
if (elms[1][scope.key].nodeId === undefined) {
|
|
2422
|
+
elms[1][scope.key].populate(elementConfig1)
|
|
2423
|
+
}
|
|
2400
2424
|
}
|
|
2401
|
-
}
|
|
2402
2425
|
}
|
|
2403
2426
|
effect(() => {
|
|
2404
|
-
|
|
2427
|
+
forloop1(component.items, elms, created1)
|
|
2405
2428
|
}, 'items')
|
|
2406
2429
|
return elms
|
|
2407
2430
|
}
|
|
@@ -2438,6 +2461,7 @@ test('Generate code for a template with double $$ (i.e. referencing a Blits plug
|
|
|
2438
2461
|
const elms = []
|
|
2439
2462
|
let componentType
|
|
2440
2463
|
const rootComponent = component
|
|
2464
|
+
let propData
|
|
2441
2465
|
const elementConfig0 = {}
|
|
2442
2466
|
|
|
2443
2467
|
elms[0] = this.element({ parent: parent || 'root' }, component)
|