glass-easel-miniprogram-adapter 0.1.1 → 0.2.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/dist/glass_easel_miniprogram_adapter.js +1 -1
- package/dist/glass_easel_miniprogram_adapter.js.map +1 -1
- package/dist/types/src/backend.d.ts +8 -0
- package/dist/types/src/backend.d.ts.map +1 -1
- package/dist/types/src/behavior.d.ts +1 -1
- package/dist/types/src/behavior.d.ts.map +1 -1
- package/dist/types/src/component.d.ts +12 -2
- package/dist/types/src/component.d.ts.map +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/intersection.d.ts +24 -0
- package/dist/types/src/intersection.d.ts.map +1 -0
- package/dist/types/src/media_query.d.ts +13 -0
- package/dist/types/src/media_query.d.ts.map +1 -0
- package/dist/types/src/selector_query.d.ts.map +1 -1
- package/dist/types/src/space.d.ts +3 -3
- package/dist/types/src/space.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +4 -4
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/utils.d.ts.map +1 -1
- package/dist/types/tests/base/env.d.ts.map +1 -1
- package/jest.config.js +1 -3
- package/package.json +5 -5
- package/src/backend.ts +20 -10
- package/src/behavior.ts +7 -29
- package/src/component.ts +56 -38
- package/src/index.ts +1 -3
- package/src/intersection.ts +119 -0
- package/src/media_query.ts +28 -0
- package/src/selector_query.ts +176 -174
- package/src/space.ts +154 -238
- package/src/types.ts +33 -33
- package/src/utils.ts +4 -3
- package/tests/base/env.ts +1 -2
- package/tests/data_update.test.ts +43 -37
- package/tests/env.test.ts +37 -37
- package/tests/selector.test.ts +295 -189
- package/tests/space.test.ts +216 -91
- package/tests/trait_behavior.test.ts +26 -23
- package/webpack.config.js +14 -13
package/tests/selector.test.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as glassEasel from 'glass-easel'
|
|
2
2
|
import { tmpl } from './base/env'
|
|
3
|
-
import {
|
|
4
|
-
MiniProgramEnv,
|
|
5
|
-
} from '../src'
|
|
3
|
+
import { MiniProgramEnv } from '../src'
|
|
6
4
|
|
|
7
5
|
const domHtml = (elem: glassEasel.Element): string => {
|
|
8
6
|
const domElem = elem.getBackendElement() as unknown as Element
|
|
@@ -42,12 +40,15 @@ describe('selector query', () => {
|
|
|
42
40
|
child: '/child/comp',
|
|
43
41
|
},
|
|
44
42
|
})
|
|
45
|
-
codeSpace.addCompiledTemplate(
|
|
43
|
+
codeSpace.addCompiledTemplate(
|
|
44
|
+
'path/to/comp',
|
|
45
|
+
tmpl(`
|
|
46
46
|
<div>
|
|
47
47
|
<child id="c1" />
|
|
48
48
|
<child id="c2" data-a="A" />
|
|
49
49
|
</div>
|
|
50
|
-
`)
|
|
50
|
+
`),
|
|
51
|
+
)
|
|
51
52
|
// eslint-disable-next-line arrow-body-style
|
|
52
53
|
const selfDef = codeSpace.componentEnv('path/to/comp', ({ Component }) => {
|
|
53
54
|
return Component()
|
|
@@ -103,12 +104,15 @@ describe('selector query', () => {
|
|
|
103
104
|
child: '/child/comp',
|
|
104
105
|
},
|
|
105
106
|
})
|
|
106
|
-
codeSpace.addCompiledTemplate(
|
|
107
|
+
codeSpace.addCompiledTemplate(
|
|
108
|
+
'path/to/comp',
|
|
109
|
+
tmpl(`
|
|
107
110
|
<div id="d">
|
|
108
111
|
<child id="c1" />
|
|
109
112
|
<child id="c2" />
|
|
110
113
|
</div>
|
|
111
|
-
`)
|
|
114
|
+
`),
|
|
115
|
+
)
|
|
112
116
|
codeSpace.componentEnv('path/to/comp', ({ Component }) => {
|
|
113
117
|
const selfDef = Component()
|
|
114
118
|
.lifetime('attached', function () {
|
|
@@ -163,13 +167,16 @@ describe('selector query', () => {
|
|
|
163
167
|
'child-b': '/child/comp2',
|
|
164
168
|
},
|
|
165
169
|
})
|
|
166
|
-
codeSpace.addCompiledTemplate(
|
|
170
|
+
codeSpace.addCompiledTemplate(
|
|
171
|
+
'path/to/comp',
|
|
172
|
+
tmpl(`
|
|
167
173
|
<div id="d">
|
|
168
174
|
<child class="c" />
|
|
169
175
|
<child class="c" />
|
|
170
176
|
<child-b class="c" />
|
|
171
177
|
</div>
|
|
172
|
-
`)
|
|
178
|
+
`),
|
|
179
|
+
)
|
|
173
180
|
codeSpace.componentEnv('path/to/comp', ({ Component }) => {
|
|
174
181
|
const selfDef = Component()
|
|
175
182
|
.lifetime('attached', function () {
|
|
@@ -185,217 +192,315 @@ describe('selector query', () => {
|
|
|
185
192
|
const ab = env.associateBackend()
|
|
186
193
|
const root = ab.createRoot('body', codeSpace, 'path/to/comp')
|
|
187
194
|
glassEasel.Element.pretendAttached(root.getComponent())
|
|
188
|
-
expect(domHtml(root.getComponent()))
|
|
189
|
-
|
|
195
|
+
expect(domHtml(root.getComponent())).toBe(
|
|
196
|
+
'<div><child class="c">0</child><child class="c">1</child><child-b class="c">2</child-b></div>',
|
|
197
|
+
)
|
|
190
198
|
})
|
|
191
199
|
|
|
192
|
-
test('query single element info', () =>
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
200
|
+
test('query single element info', () =>
|
|
201
|
+
new Promise<any[]>((resolve) => {
|
|
202
|
+
const env = new MiniProgramEnv()
|
|
203
|
+
const codeSpace = env.createCodeSpace('', true)
|
|
204
|
+
const resList = [] as any[]
|
|
196
205
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
.register()
|
|
205
|
-
})
|
|
206
|
+
codeSpace.addComponentStaticConfig('child/comp', {
|
|
207
|
+
component: true,
|
|
208
|
+
})
|
|
209
|
+
codeSpace.addCompiledTemplate('child/comp', tmpl('{{a}}'))
|
|
210
|
+
codeSpace.componentEnv('child/comp', ({ Component }) => {
|
|
211
|
+
Component().property('p', String).register()
|
|
212
|
+
})
|
|
206
213
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
214
|
+
codeSpace.addComponentStaticConfig('path/to/comp', {
|
|
215
|
+
usingComponents: {
|
|
216
|
+
child: '/child/comp',
|
|
217
|
+
},
|
|
218
|
+
})
|
|
219
|
+
codeSpace.addCompiledTemplate(
|
|
220
|
+
'path/to/comp',
|
|
221
|
+
tmpl(`
|
|
213
222
|
<div data-a="{{ 1 }}" mark:a="a2">
|
|
214
223
|
<span id="bb" class="s" data-b="{{ 1 }}" mark:b="b2" />
|
|
215
224
|
<child id="cc" class="s" data-c="{{ 1 }}" mark:c="c2" p="123" />
|
|
216
225
|
</div>
|
|
217
|
-
`)
|
|
218
|
-
|
|
219
|
-
Component
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
.
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
.
|
|
226
|
+
`),
|
|
227
|
+
)
|
|
228
|
+
codeSpace.componentEnv('path/to/comp', ({ Component }) => {
|
|
229
|
+
Component()
|
|
230
|
+
.lifetime('attached', function () {
|
|
231
|
+
this.createSelectorQuery()
|
|
232
|
+
.select('.invalid')
|
|
233
|
+
.fields({})
|
|
234
|
+
.select('.s')
|
|
235
|
+
.boundingClientRect((res) => {
|
|
236
|
+
expect(res.id).toBe('bb')
|
|
237
|
+
expect(res.dataset).toStrictEqual({ b: 1 })
|
|
238
|
+
expect(typeof res.left).toBe('number')
|
|
239
|
+
expect(typeof res.top).toBe('number')
|
|
240
|
+
expect(typeof res.right).toBe('number')
|
|
241
|
+
expect(typeof res.bottom).toBe('number')
|
|
242
|
+
expect(typeof res.width).toBe('number')
|
|
243
|
+
expect(typeof res.height).toBe('number')
|
|
244
|
+
resList.push(res)
|
|
245
|
+
})
|
|
246
|
+
.select('#bb')
|
|
247
|
+
.scrollOffset((res) => {
|
|
248
|
+
expect(res.id).toBe('bb')
|
|
249
|
+
expect(res.dataset).toStrictEqual({ b: 1 })
|
|
250
|
+
expect(typeof res.scrollLeft).toBe('number')
|
|
251
|
+
expect(typeof res.scrollTop).toBe('number')
|
|
252
|
+
expect(typeof res.scrollWidth).toBe('number')
|
|
253
|
+
expect(typeof res.scrollHeight).toBe('number')
|
|
254
|
+
resList.push(res)
|
|
255
|
+
})
|
|
256
|
+
.select('#cc')
|
|
257
|
+
.fields(
|
|
258
|
+
{
|
|
259
|
+
mark: true,
|
|
260
|
+
rect: true,
|
|
261
|
+
size: true,
|
|
262
|
+
scrollOffset: true,
|
|
263
|
+
properties: ['p'],
|
|
264
|
+
},
|
|
265
|
+
(res) => {
|
|
266
|
+
expect(res.id).toBe(undefined)
|
|
267
|
+
expect(res.dataset).toBe(undefined)
|
|
268
|
+
expect(res.mark).toStrictEqual({ a: 'a2', c: 'c2' })
|
|
269
|
+
expect(typeof res.left).toBe('number')
|
|
270
|
+
expect(typeof res.top).toBe('number')
|
|
271
|
+
expect(typeof res.right).toBe('number')
|
|
272
|
+
expect(typeof res.bottom).toBe('number')
|
|
273
|
+
expect(typeof res.width).toBe('number')
|
|
274
|
+
expect(typeof res.height).toBe('number')
|
|
275
|
+
expect(typeof res.scrollLeft).toBe('number')
|
|
276
|
+
expect(typeof res.scrollTop).toBe('number')
|
|
277
|
+
expect(typeof res.scrollWidth).toBe('number')
|
|
278
|
+
expect(typeof res.scrollHeight).toBe('number')
|
|
279
|
+
expect(res.p).toBe('123')
|
|
280
|
+
resList.push(res)
|
|
281
|
+
},
|
|
282
|
+
)
|
|
283
|
+
.in(this.selectComponent('#cc'))
|
|
284
|
+
.select('#cc')
|
|
285
|
+
.boundingClientRect((res) => {
|
|
286
|
+
expect(res).toBe(null)
|
|
287
|
+
})
|
|
288
|
+
.exec((r) => {
|
|
289
|
+
r.shift()
|
|
290
|
+
r.pop()
|
|
291
|
+
expect(r).toStrictEqual(resList)
|
|
292
|
+
this.createSelectorQuery().exec(() => {
|
|
281
293
|
resolve(resList)
|
|
282
294
|
})
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
295
|
+
})
|
|
296
|
+
})
|
|
297
|
+
.register()
|
|
298
|
+
})
|
|
287
299
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
300
|
+
const ab = env.associateBackend()
|
|
301
|
+
const root = ab.createRoot('body', codeSpace, 'path/to/comp')
|
|
302
|
+
glassEasel.Element.pretendAttached(root.getComponent())
|
|
303
|
+
}).then((resList: any[]) => {
|
|
304
|
+
expect(resList.length).toBe(3)
|
|
305
|
+
return undefined
|
|
306
|
+
}))
|
|
295
307
|
|
|
296
|
-
test('query multiple element info', () =>
|
|
297
|
-
|
|
298
|
-
|
|
308
|
+
test('query multiple element info', () =>
|
|
309
|
+
new Promise<undefined>((resolve) => {
|
|
310
|
+
const env = new MiniProgramEnv()
|
|
311
|
+
const codeSpace = env.createCodeSpace('', true)
|
|
299
312
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
codeSpace.addComponentStaticConfig('child/comp', {
|
|
314
|
+
component: true,
|
|
315
|
+
})
|
|
316
|
+
codeSpace.addCompiledTemplate('child/comp', tmpl('{{a}}'))
|
|
317
|
+
codeSpace.componentEnv('child/comp', ({ Component }) => {
|
|
318
|
+
Component()
|
|
319
|
+
.options({
|
|
320
|
+
propertyPassingDeepCopy: glassEasel.DeepCopyKind.None,
|
|
321
|
+
})
|
|
322
|
+
.property('p', {
|
|
323
|
+
type: Array,
|
|
324
|
+
value: [1, 2, 3],
|
|
325
|
+
})
|
|
326
|
+
.register()
|
|
327
|
+
})
|
|
315
328
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
329
|
+
codeSpace.addComponentStaticConfig('path/to/comp', {
|
|
330
|
+
usingComponents: {
|
|
331
|
+
child: '/child/comp',
|
|
332
|
+
},
|
|
333
|
+
})
|
|
334
|
+
codeSpace.addCompiledTemplate(
|
|
335
|
+
'path/to/comp',
|
|
336
|
+
tmpl(`
|
|
322
337
|
<div data-a="{{ 1 }}" mark:a="a2">
|
|
323
338
|
<span id="bb" class="s" data-b="{{ 1 }}" mark:b="b2" />
|
|
324
339
|
<child id="cc" class="s" data-c="{{ 1 }}" mark:c="c2" />
|
|
325
340
|
</div>
|
|
326
|
-
`)
|
|
327
|
-
|
|
328
|
-
Component
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
.
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
mark: {
|
|
338
|
-
a: 'a2',
|
|
339
|
-
b: 'b2',
|
|
341
|
+
`),
|
|
342
|
+
)
|
|
343
|
+
codeSpace.componentEnv('path/to/comp', ({ Component }) => {
|
|
344
|
+
Component()
|
|
345
|
+
.lifetime('attached', function () {
|
|
346
|
+
this.createSelectorQuery()
|
|
347
|
+
.selectAll('.s')
|
|
348
|
+
.fields(
|
|
349
|
+
{
|
|
350
|
+
mark: true,
|
|
351
|
+
properties: ['p'],
|
|
340
352
|
},
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
353
|
+
(res) => {
|
|
354
|
+
expect(res).toStrictEqual([
|
|
355
|
+
{
|
|
356
|
+
mark: {
|
|
357
|
+
a: 'a2',
|
|
358
|
+
b: 'b2',
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
mark: {
|
|
363
|
+
a: 'a2',
|
|
364
|
+
c: 'c2',
|
|
365
|
+
},
|
|
366
|
+
p: [1, 2, 3],
|
|
367
|
+
},
|
|
368
|
+
])
|
|
369
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
370
|
+
expect(res[1]!.p).toBe(this.selectComponent('#cc').data.p)
|
|
371
|
+
resolve(undefined)
|
|
345
372
|
},
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
373
|
+
)
|
|
374
|
+
.exec()
|
|
375
|
+
})
|
|
376
|
+
.register()
|
|
377
|
+
})
|
|
378
|
+
|
|
379
|
+
const ab = env.associateBackend()
|
|
380
|
+
const root = ab.createRoot('body', codeSpace, 'path/to/comp')
|
|
381
|
+
glassEasel.Element.pretendAttached(root.getComponent())
|
|
382
|
+
}))
|
|
383
|
+
|
|
384
|
+
test('query viewport info', () =>
|
|
385
|
+
new Promise<undefined>((resolve) => {
|
|
386
|
+
const env = new MiniProgramEnv()
|
|
387
|
+
const codeSpace = env.createCodeSpace('', true)
|
|
388
|
+
|
|
389
|
+
codeSpace.addComponentStaticConfig('path/to/comp', {})
|
|
390
|
+
codeSpace.addCompiledTemplate('path/to/comp', tmpl(''))
|
|
391
|
+
codeSpace.componentEnv('path/to/comp', ({ Component }) => {
|
|
392
|
+
Component()
|
|
393
|
+
.lifetime('attached', function () {
|
|
394
|
+
this.createSelectorQuery()
|
|
395
|
+
.selectViewport()
|
|
396
|
+
.fields(
|
|
397
|
+
{
|
|
398
|
+
id: true,
|
|
399
|
+
dataset: true,
|
|
400
|
+
mark: true,
|
|
401
|
+
rect: true,
|
|
402
|
+
size: true,
|
|
403
|
+
scrollOffset: true,
|
|
404
|
+
properties: ['p'],
|
|
405
|
+
},
|
|
406
|
+
(res) => {
|
|
407
|
+
expect(res.id).toBe('')
|
|
408
|
+
expect(res.dataset).toStrictEqual({})
|
|
409
|
+
expect(res.mark).toStrictEqual({})
|
|
410
|
+
expect(typeof res.left).toBe('number')
|
|
411
|
+
expect(typeof res.top).toBe('number')
|
|
412
|
+
expect(typeof res.right).toBe('number')
|
|
413
|
+
expect(typeof res.bottom).toBe('number')
|
|
414
|
+
expect(typeof res.width).toBe('number')
|
|
415
|
+
expect(typeof res.height).toBe('number')
|
|
416
|
+
expect(typeof res.scrollLeft).toBe('number')
|
|
417
|
+
expect(typeof res.scrollTop).toBe('number')
|
|
418
|
+
expect(typeof res.scrollWidth).toBe('number')
|
|
419
|
+
expect(typeof res.scrollHeight).toBe('number')
|
|
420
|
+
expect(res.p).toBe(undefined)
|
|
421
|
+
resolve(undefined)
|
|
422
|
+
},
|
|
423
|
+
)
|
|
424
|
+
.exec()
|
|
425
|
+
})
|
|
426
|
+
.register()
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
const ab = env.associateBackend()
|
|
430
|
+
const root = ab.createRoot('body', codeSpace, 'path/to/comp')
|
|
431
|
+
glassEasel.Element.pretendAttached(root.getComponent())
|
|
432
|
+
}))
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
describe('intersection observer', () => {
|
|
436
|
+
test('create intersection observer', () => {
|
|
437
|
+
const env = new MiniProgramEnv()
|
|
438
|
+
const codeSpace = env.createCodeSpace('', true)
|
|
439
|
+
|
|
440
|
+
codeSpace.addComponentStaticConfig('path/to/comp', {
|
|
441
|
+
usingComponents: {},
|
|
442
|
+
})
|
|
443
|
+
codeSpace.addCompiledTemplate(
|
|
444
|
+
'path/to/comp',
|
|
445
|
+
tmpl(`
|
|
446
|
+
<div id="a">
|
|
447
|
+
<div id="b" />
|
|
448
|
+
<div id="b" />
|
|
449
|
+
</div>
|
|
450
|
+
`),
|
|
451
|
+
)
|
|
452
|
+
// eslint-disable-next-line arrow-body-style
|
|
453
|
+
codeSpace.componentEnv('path/to/comp', ({ Component }) => {
|
|
454
|
+
return Component()
|
|
455
|
+
.lifetime('attached', function () {
|
|
456
|
+
const o1 = this.createIntersectionObserver().relativeToViewport()
|
|
457
|
+
o1.observe('#a', () => {
|
|
458
|
+
/* empty */
|
|
459
|
+
})
|
|
460
|
+
const o2 = this.createIntersectionObserver({
|
|
461
|
+
thresholds: [1],
|
|
462
|
+
initialRatio: 0,
|
|
463
|
+
observeAll: true,
|
|
464
|
+
}).relativeTo('#a')
|
|
465
|
+
o2.observe('#b', () => {
|
|
466
|
+
/* empty */
|
|
467
|
+
})
|
|
468
|
+
o1.disconnect()
|
|
469
|
+
o2.disconnect()
|
|
353
470
|
})
|
|
354
471
|
.register()
|
|
355
472
|
})
|
|
356
473
|
|
|
357
|
-
const
|
|
474
|
+
const backendContext = new glassEasel.composedBackend.EmptyComposedBackendContext()
|
|
475
|
+
const ab = env.associateBackend(backendContext)
|
|
358
476
|
const root = ab.createRoot('body', codeSpace, 'path/to/comp')
|
|
359
477
|
glassEasel.Element.pretendAttached(root.getComponent())
|
|
360
|
-
})
|
|
478
|
+
})
|
|
479
|
+
})
|
|
361
480
|
|
|
362
|
-
|
|
481
|
+
describe('media query observer', () => {
|
|
482
|
+
test('create media query observer', () => {
|
|
363
483
|
const env = new MiniProgramEnv()
|
|
364
484
|
const codeSpace = env.createCodeSpace('', true)
|
|
365
485
|
|
|
366
|
-
codeSpace.addComponentStaticConfig('path/to/comp', {
|
|
367
|
-
|
|
486
|
+
codeSpace.addComponentStaticConfig('path/to/comp', {
|
|
487
|
+
usingComponents: {},
|
|
488
|
+
})
|
|
489
|
+
codeSpace.addCompiledTemplate(
|
|
490
|
+
'path/to/comp',
|
|
491
|
+
tmpl(`
|
|
492
|
+
<div id="a" />
|
|
493
|
+
`),
|
|
494
|
+
)
|
|
495
|
+
// eslint-disable-next-line arrow-body-style
|
|
368
496
|
codeSpace.componentEnv('path/to/comp', ({ Component }) => {
|
|
369
|
-
Component()
|
|
497
|
+
return Component()
|
|
370
498
|
.lifetime('attached', function () {
|
|
371
|
-
this.
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
mark: true,
|
|
377
|
-
rect: true,
|
|
378
|
-
size: true,
|
|
379
|
-
scrollOffset: true,
|
|
380
|
-
properties: ['p'],
|
|
381
|
-
}, (res) => {
|
|
382
|
-
expect(res.id).toBe('')
|
|
383
|
-
expect(res.dataset).toStrictEqual({})
|
|
384
|
-
expect(res.mark).toStrictEqual({})
|
|
385
|
-
expect(typeof res.left).toBe('number')
|
|
386
|
-
expect(typeof res.top).toBe('number')
|
|
387
|
-
expect(typeof res.right).toBe('number')
|
|
388
|
-
expect(typeof res.bottom).toBe('number')
|
|
389
|
-
expect(typeof res.width).toBe('number')
|
|
390
|
-
expect(typeof res.height).toBe('number')
|
|
391
|
-
expect(typeof res.scrollLeft).toBe('number')
|
|
392
|
-
expect(typeof res.scrollTop).toBe('number')
|
|
393
|
-
expect(typeof res.scrollWidth).toBe('number')
|
|
394
|
-
expect(typeof res.scrollHeight).toBe('number')
|
|
395
|
-
expect(res.p).toBe(undefined)
|
|
396
|
-
resolve(undefined)
|
|
397
|
-
})
|
|
398
|
-
.exec()
|
|
499
|
+
const o = this.createMediaQueryObserver()
|
|
500
|
+
o.observe({ orientation: 'landscape' }, () => {
|
|
501
|
+
/* empty */
|
|
502
|
+
})
|
|
503
|
+
o.disconnect()
|
|
399
504
|
})
|
|
400
505
|
.register()
|
|
401
506
|
})
|
|
@@ -403,5 +508,6 @@ describe('selector query', () => {
|
|
|
403
508
|
const ab = env.associateBackend()
|
|
404
509
|
const root = ab.createRoot('body', codeSpace, 'path/to/comp')
|
|
405
510
|
glassEasel.Element.pretendAttached(root.getComponent())
|
|
406
|
-
|
|
511
|
+
expect(domHtml(root.getComponent())).toBe('<div></div>')
|
|
512
|
+
})
|
|
407
513
|
})
|