@@ -121,14 +121,14 @@ class TestHTMLRenderer extends TestCase implements IthrilView {
121
121
class TestIthil extends TestCase implements IthrilView {
122
122
123
123
public function testBasic () {
124
- assert ({tag : ' div' , attrs : {}, children : [] }, [(div )]);
124
+ assert ({tag : ' div' , attrs : {}}, [(div )]);
125
125
}
126
126
127
127
public function testClassname () {
128
- assert ({tag : ' div' , attrs : {' class' : ' test' }, children : [] }, [(div .test )]);
129
- assert ({tag : ' div' , attrs : {' class' : ' test second' }, children : [] }, [(div .test .second )]);
130
- assert ({tag : ' div' , attrs : {' class' : ' test-with-hyphen' }, children : [] }, [(div .test - with - hyphen )]);
131
- assert ({tag : ' div' , attrs : {' class' : [' c1' , ' c2' ]}, children : [] }, [(div (' class' = [' c1' , ' c2' ]))]);
128
+ assert ({tag : ' div' , attrs : {' class' : ' test' }}, [(div .test )]);
129
+ assert ({tag : ' div' , attrs : {' class' : ' test second' }}, [(div .test .second )]);
130
+ assert ({tag : ' div' , attrs : {' class' : ' test-with-hyphen' }}, [(div .test - with - hyphen )]);
131
+ assert ({tag : ' div' , attrs : {' class' : [' c1' , ' c2' ]}}, [(div (' class' = [' c1' , ' c2' ]))]);
132
132
}
133
133
134
134
/**
@@ -138,92 +138,91 @@ class TestIthil extends TestCase implements IthrilView {
138
138
* It does not, however, de-dupe classes if the same class is declared twice.
139
139
*/
140
140
public function testClassnameCombine () {
141
- assert ({tag : ' div' , attrs : {' class' : ' test test2' }, children : [] }, [(div .test (' class' = ' test2' ))]);
142
- assert ({tag : ' div' , attrs : {' class' : ' test test2' }, children : [] }, [(div .test (' class' = [' test2' ]))]);
143
- assert ({tag : ' div' , attrs : {' class' : ' test test2' }, children : [] }, [(div (' class' = ' test' ) (' class' = ' test2' ))]);
141
+ assert ({tag : ' div' , attrs : {' class' : ' test test2' }}, [(div .test (' class' = ' test2' ))]);
142
+ assert ({tag : ' div' , attrs : {' class' : ' test test2' }}, [(div .test (' class' = [' test2' ]))]);
143
+ assert ({tag : ' div' , attrs : {' class' : ' test test2' }}, [(div (' class' = ' test' ) (' class' = ' test2' ))]);
144
144
}
145
145
146
146
public function testId () {
147
- assert ({tag : ' div' , attrs : {' id' : ' test' }, children : [] }, [(div + test )]);
148
- assert ({tag : ' div' , attrs : {' id' : ' test-with-hyphen' }, children : [] }, [(div + test - with - hyphen )]);
147
+ assert ({tag : ' div' , attrs : {' id' : ' test' }}, [(div + test )]);
148
+ assert ({tag : ' div' , attrs : {' id' : ' test-with-hyphen' }}, [(div + test - with - hyphen )]);
149
149
}
150
150
151
151
public function testChildren () {
152
- assert ({tag : ' div' , children : ([{tag : ' div' , attrs : {}, children : [] }]: Dynamic )}, [
152
+ assert ({tag : ' div' , children : ([{tag : ' div' , attrs : {}}]: Dynamic )}, [
153
153
(div )
154
154
(div )
155
155
]);
156
156
157
- assert ({tag : ' div' , children : ([{tag : ' div' , children : [{tag : ' div' , attrs : {}, children : [] }]}]: Dynamic )}, [
157
+ assert ({tag : ' div' , children : ([{tag : ' div' , children : [{tag : ' div' , attrs : {}}]}]: Dynamic )}, [
158
158
(div )
159
159
(div )
160
160
(div )
161
161
]);
162
162
163
- assert ({tag : ' div' , children : ([{tag : ' div' , attrs : {}, children : [] }, {tag : ' div' , attrs : {}, children : [] }]: Dynamic )}, [
163
+ assert ({tag : ' div' , children : ([{tag : ' div' , attrs : {}}, {tag : ' div' , attrs : {}}]: Dynamic )}, [
164
164
(div )
165
165
(div )(div )
166
166
]);
167
167
168
- assert ({tag : ' div' , children : ([{tag : ' div' , attrs : {}, children : [] }, {tag : ' div' , attrs : {}, children : [] }]: Dynamic )}, [
168
+ assert ({tag : ' div' , children : ([{tag : ' div' , attrs : {}}, {tag : ' div' , attrs : {}}]: Dynamic )}, [
169
169
(div )
170
170
(div )
171
171
(div )
172
172
]);
173
173
174
- assert (([ { " children" : [ { " children " : [], " tag" : " div" , " attrs" : {} } ], " tag" : " div" }, { " children " : [], " tag" : " div" , " attrs" : {} } ]: Dynamic ), [
174
+ assert (([ { " children" : [ { " tag" : " div" , " attrs" : {} } ], " tag" : " div" }, { " tag" : " div" , " attrs" : {} } ]: Dynamic ), [
175
175
(div )
176
176
(div )
177
177
(div )
178
178
]);
179
179
}
180
180
181
181
public function testAttribute () {
182
- assert ({tag : ' div' , attrs : {attr : ' test' }, children : [] }, [(div [attr = ' test' ])]);
183
- assert ({tag : ' div' , attrs : {attr : ' test' , second : ' test' }, children : [] }, [(div [attr = ' test' ][second = ' test' ])]);
182
+ assert ({tag : ' div' , attrs : {attr : ' test' }}, [(div [attr = ' test' ])]);
183
+ assert ({tag : ' div' , attrs : {attr : ' test' , second : ' test' }}, [(div [attr = ' test' ][second = ' test' ])]);
184
184
}
185
185
186
186
public function testCallableAttribute () {
187
187
function attr (): {attr :String } return {
188
188
attr : ' test'
189
189
}
190
- assert ({tag : ' div' , attrs : {attr : ' test' }, children : [] }, [(div (attr ))]);
190
+ assert ({tag : ' div' , attrs : {attr : ' test' }}, [(div (attr ))]);
191
191
}
192
192
193
193
public function testCombineAttributes () {
194
- assert ({tag : ' div' , attrs : {a : 1 , b : 2 }, children : [] }, [
194
+ assert ({tag : ' div' , attrs : {a : 1 , b : 2 }}, [
195
195
(div (a = 1 ) (b = 2 ))
196
196
]);
197
- assert ({tag : ' div' , attrs : {a : 1 }, children : [] }, [
197
+ assert ({tag : ' div' , attrs : {a : 1 }}, [
198
198
(div (a = 1 ) (a = 2 ))
199
199
]);
200
200
function attr () return {
201
201
attr : ' test'
202
202
}
203
- assert ({tag : ' div' , attrs : {a : 1 , attr : ' test' }, children : [] }, [
203
+ assert ({tag : ' div' , attrs : {a : 1 , attr : ' test' }}, [
204
204
(div (a = 1 ) (attr ))
205
205
]);
206
- assert ({ " children " : " ok" , " tag" : " div" , " attrs" : { " attr" : " test" , " a" : 1 , " id" : " id" } }, [
206
+ assert ({ " text " : " ok" , " tag" : " div" , " attrs" : { " attr" : " test" , " a" : 1 , " id" : " id" } }, [
207
207
(div + id (a = 1 ) (attr ) > ' ok' )
208
208
]);
209
209
}
210
210
211
211
public function testCombination () {
212
- assert ({tag : ' div' , attrs : {' class' : ' test' , id : ' test' , attr : ' test' }, children : [] }, [(div [attr = ' test' ].test + test )]);
213
- assert ({ " children " : " a" , " tag" : " div" , " attrs" : { " attr" : " test" , " class" : " test" , " id" : " test" } }, [(div [attr = ' test' ].test + test > ' a' )]);
214
- assert ({tag : ' div' , attrs : {' class' : ' test' , id : ' test' , attr : ' test' , attr2 : ' test' }, children : [] }, [(div [attr = ' test' ].test + test [attr2 = ' test' ])]);
212
+ assert ({tag : ' div' , attrs : {' class' : ' test' , id : ' test' , attr : ' test' }}, [(div [attr = ' test' ].test + test )]);
213
+ assert ({ " text " : " a" , " tag" : " div" , " attrs" : { " attr" : " test" , " class" : " test" , " id" : " test" } }, [(div [attr = ' test' ].test + test > ' a' )]);
214
+ assert ({tag : ' div' , attrs : {' class' : ' test' , id : ' test' , attr : ' test' , attr2 : ' test' }}, [(div [attr = ' test' ].test + test [attr2 = ' test' ])]);
215
215
}
216
216
217
217
public function testTextnode () {
218
218
assert ({
219
219
" text" : " Test" ,
220
- " children" : [],
221
220
" tag" : " div"
222
221
}, [(div > ' Test' )]);
223
222
}
224
223
225
224
public function testAddToExistingAttributes () {
226
- var expected = {tag : ' div' , attrs : {attr : ' test' , id : ' test' , ' class' : ' test' }, children : [] };
225
+ var expected = {tag : ' div' , attrs : {attr : ' test' , id : ' test' , ' class' : ' test' }};
227
226
assert (expected , [(div .test + test (attr = ' test' ))]);
228
227
assert (expected , [(div .test + test
229
228
((function (): Dynamic {
@@ -268,7 +267,7 @@ class TestIthil extends TestCase implements IthrilView {
268
267
}
269
268
270
269
public function testCustomElement () {
271
- assert ({tag : ' div' , attrs : {attr : ' test' }, children : [] }, new CustomElement ().view ({ tag : ' ' , attrs : { attr : ' test' } }));
270
+ assert ({tag : ' div' , attrs : {attr : ' test' }}, new CustomElement ({ } ).view ({ tag : ' ' , attrs : { attr : ' test' } }));
272
271
}
273
272
274
273
public function testCustomElementKeepRef () {
0 commit comments