@enact/spotlight 5.3.1 → 5.4.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.
@@ -93,7 +93,7 @@ var teardownContainers = function teardownContainers() {
93
93
  (0, _container10.setDefaultContainer)();
94
94
  };
95
95
 
96
- // NOTE: Skipping most tests because JSDOM does not support measurments
96
+ // NOTE: Skipping most tests because JSDOM does not support measurements
97
97
  describe('target', function () {
98
98
  beforeEach(setupContainers);
99
99
  afterEach(teardownContainers);
@@ -252,10 +252,54 @@ describe('target', function () {
252
252
  expect((0, _target.getTargetBySelector)('')).toBe(expected);
253
253
  }));
254
254
  });
255
- describe.skip('#getTargetByDirectionFromElement', function () {
255
+ describe('#getTargetByDirectionFromElement', function () {
256
256
  test('should find target within container by direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
257
257
  (0, _container10.configureContainer)('grid');
258
258
  var center = root.querySelector('#middle-center');
259
+ var topCenter = root.querySelector('#top-center');
260
+ var bottomCenter = root.querySelector('#bottom-center');
261
+ var middleLeft = root.querySelector('#middle-left');
262
+ var middleRight = root.querySelector('#middle-right');
263
+ center.getBoundingClientRect = function () {
264
+ return {
265
+ top: 10,
266
+ left: 10,
267
+ width: 10,
268
+ height: 10
269
+ };
270
+ };
271
+ topCenter.getBoundingClientRect = function () {
272
+ return {
273
+ top: 0,
274
+ left: 10,
275
+ width: 10,
276
+ height: 10
277
+ };
278
+ };
279
+ bottomCenter.getBoundingClientRect = function () {
280
+ return {
281
+ top: 20,
282
+ left: 10,
283
+ width: 10,
284
+ height: 10
285
+ };
286
+ };
287
+ middleLeft.getBoundingClientRect = function () {
288
+ return {
289
+ top: 10,
290
+ left: 0,
291
+ width: 10,
292
+ height: 10
293
+ };
294
+ };
295
+ middleRight.getBoundingClientRect = function () {
296
+ return {
297
+ top: 10,
298
+ left: 20,
299
+ width: 10,
300
+ height: 10
301
+ };
302
+ };
259
303
  expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', center), function (t) {
260
304
  return t.id;
261
305
  })).toBe('top-center');
@@ -272,9 +316,133 @@ describe('target', function () {
272
316
  test('should find target within container from floating element', (0, _utils.testScenario)(scenarios.overlap, function (root) {
273
317
  (0, _container10.configureContainer)('grid', {
274
318
  enterTo: 'default-element',
275
- defaultElement: '#bottom-right'
319
+ defaultElement: '#middle-center'
276
320
  });
321
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
277
322
  var overlap = root.querySelector('#over-middle-center');
323
+ var center = root.querySelector('#middle-center');
324
+ var topLeft = root.querySelector('#top-left');
325
+ var topCenter = root.querySelector('#top-center');
326
+ var topRight = root.querySelector('#top-right');
327
+ var middleLeft = root.querySelector('#middle-left');
328
+ var middleRight = root.querySelector('#middle-right');
329
+ var bottomLeft = root.querySelector('#bottom-left');
330
+ var bottomCenter = root.querySelector('#bottom-center');
331
+ var bottomRight = root.querySelector('#bottom-right');
332
+
333
+ // Mock getBoundingClientRect for all elements
334
+ gridContainer.getBoundingClientRect = function () {
335
+ return {
336
+ top: 10,
337
+ left: 10,
338
+ width: 30,
339
+ height: 30,
340
+ right: 40,
341
+ bottom: 40
342
+ };
343
+ };
344
+ topLeft.getBoundingClientRect = function () {
345
+ return {
346
+ top: 10,
347
+ left: 10,
348
+ width: 10,
349
+ height: 10,
350
+ right: 20,
351
+ bottom: 20
352
+ };
353
+ };
354
+ topCenter.getBoundingClientRect = function () {
355
+ return {
356
+ top: 10,
357
+ left: 20,
358
+ width: 10,
359
+ height: 10,
360
+ right: 30,
361
+ bottom: 20
362
+ };
363
+ };
364
+ topRight.getBoundingClientRect = function () {
365
+ return {
366
+ top: 10,
367
+ left: 30,
368
+ width: 10,
369
+ height: 10,
370
+ right: 40,
371
+ bottom: 20
372
+ };
373
+ };
374
+ middleLeft.getBoundingClientRect = function () {
375
+ return {
376
+ top: 20,
377
+ left: 10,
378
+ width: 10,
379
+ height: 10,
380
+ right: 20,
381
+ bottom: 30
382
+ };
383
+ };
384
+ center.getBoundingClientRect = function () {
385
+ return {
386
+ top: 20,
387
+ left: 20,
388
+ width: 10,
389
+ height: 10,
390
+ right: 30,
391
+ bottom: 30
392
+ };
393
+ };
394
+ middleRight.getBoundingClientRect = function () {
395
+ return {
396
+ top: 20,
397
+ left: 30,
398
+ width: 10,
399
+ height: 10,
400
+ right: 40,
401
+ bottom: 30
402
+ };
403
+ };
404
+ bottomLeft.getBoundingClientRect = function () {
405
+ return {
406
+ top: 30,
407
+ left: 10,
408
+ width: 10,
409
+ height: 10,
410
+ right: 20,
411
+ bottom: 40
412
+ };
413
+ };
414
+ bottomCenter.getBoundingClientRect = function () {
415
+ return {
416
+ top: 30,
417
+ left: 20,
418
+ width: 10,
419
+ height: 10,
420
+ right: 30,
421
+ bottom: 40
422
+ };
423
+ };
424
+ bottomRight.getBoundingClientRect = function () {
425
+ return {
426
+ top: 30,
427
+ left: 30,
428
+ width: 10,
429
+ height: 10,
430
+ right: 40,
431
+ bottom: 40
432
+ };
433
+ };
434
+
435
+ // Overlap is a small element floating over middle-center
436
+ overlap.getBoundingClientRect = function () {
437
+ return {
438
+ top: 22,
439
+ left: 25,
440
+ width: 1,
441
+ height: 1,
442
+ right: 26,
443
+ bottom: 23
444
+ };
445
+ };
278
446
  expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', overlap), function (t) {
279
447
  return t.id;
280
448
  })).toBe('middle-center');
@@ -283,7 +451,63 @@ describe('target', function () {
283
451
  (0, _container10.configureContainer)('overflow-container', {
284
452
  overflow: true
285
453
  });
454
+ var overflowContainer = root.querySelector('[data-spotlight-id="overflow-container"]');
286
455
  var element = root.querySelector('#outside-overflow');
456
+ var overflowAbove = root.querySelector('#overflow-above');
457
+ var overflowBelow = root.querySelector('#overflow-below');
458
+ var overflowWithin = root.querySelector('#overflow-within');
459
+
460
+ // Mock all bounding rects
461
+ overflowContainer.getBoundingClientRect = function () {
462
+ return {
463
+ top: 110,
464
+ left: 10,
465
+ width: 30,
466
+ height: 30,
467
+ right: 40,
468
+ bottom: 140
469
+ };
470
+ };
471
+ element.getBoundingClientRect = function () {
472
+ return {
473
+ top: 10,
474
+ left: 10,
475
+ width: 10,
476
+ height: 10,
477
+ right: 20,
478
+ bottom: 20
479
+ };
480
+ };
481
+ overflowAbove.getBoundingClientRect = function () {
482
+ return {
483
+ top: 0,
484
+ left: 10,
485
+ width: 10,
486
+ height: 10,
487
+ right: 20,
488
+ bottom: 110
489
+ };
490
+ };
491
+ overflowWithin.getBoundingClientRect = function () {
492
+ return {
493
+ top: 110,
494
+ left: 10,
495
+ width: 10,
496
+ height: 10,
497
+ right: 20,
498
+ bottom: 120
499
+ };
500
+ };
501
+ overflowBelow.getBoundingClientRect = function () {
502
+ return {
503
+ top: 140,
504
+ left: 10,
505
+ width: 10,
506
+ height: 10,
507
+ right: 20,
508
+ bottom: 150
509
+ };
510
+ };
287
511
  expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
288
512
  return t.id;
289
513
  })).toBe('overflow-within');
@@ -295,7 +519,63 @@ describe('target', function () {
295
519
  (0, _container10.configureContainer)('inside', {
296
520
  enterTo: null
297
521
  });
522
+ var overflowContainer = root.querySelector('[data-spotlight-id="overflow-container"]');
523
+ var insideContainer = root.querySelector('[data-spotlight-id="inside"]');
298
524
  var element = root.querySelector('#outside-overflow');
525
+ var inLargeContainer = root.querySelector('#in-large-container');
526
+ var belowLargeContainer = root.querySelector('#below-large-container');
527
+
528
+ // Mock all bounding rects
529
+ overflowContainer.getBoundingClientRect = function () {
530
+ return {
531
+ top: 110,
532
+ left: 10,
533
+ width: 30,
534
+ height: 30,
535
+ right: 40,
536
+ bottom: 140
537
+ };
538
+ };
539
+ insideContainer.getBoundingClientRect = function () {
540
+ return {
541
+ top: 100,
542
+ left: 10,
543
+ width: 10,
544
+ height: 50,
545
+ right: 20,
546
+ bottom: 150
547
+ };
548
+ };
549
+ element.getBoundingClientRect = function () {
550
+ return {
551
+ top: 10,
552
+ left: 10,
553
+ width: 10,
554
+ height: 10,
555
+ right: 20,
556
+ bottom: 20
557
+ };
558
+ };
559
+ inLargeContainer.getBoundingClientRect = function () {
560
+ return {
561
+ top: 110,
562
+ left: 10,
563
+ width: 10,
564
+ height: 10,
565
+ right: 20,
566
+ bottom: 120
567
+ };
568
+ };
569
+ belowLargeContainer.getBoundingClientRect = function () {
570
+ return {
571
+ top: 150,
572
+ left: 10,
573
+ width: 10,
574
+ height: 10,
575
+ right: 20,
576
+ bottom: 160
577
+ };
578
+ };
299
579
  expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
300
580
  return t.id;
301
581
  })).toBe('in-large-container');
@@ -304,34 +584,200 @@ describe('target', function () {
304
584
  (0, _container10.configureContainer)('overflow-container', {
305
585
  overflow: true
306
586
  });
307
- var element = root.querySelector('#overflow-within');
308
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
587
+ var overflowContainer = root.querySelector('[data-spotlight-id="overflow-container"]');
588
+ var overflowAbove = root.querySelector('#overflow-above');
589
+ var overflowBelow = root.querySelector('#overflow-below');
590
+ var overflowWithin = root.querySelector('#overflow-within');
591
+
592
+ // Mock all bounding rects
593
+ overflowContainer.getBoundingClientRect = function () {
594
+ return {
595
+ top: 110,
596
+ left: 10,
597
+ width: 30,
598
+ height: 30,
599
+ right: 40,
600
+ bottom: 140
601
+ };
602
+ };
603
+ overflowAbove.getBoundingClientRect = function () {
604
+ return {
605
+ top: 100,
606
+ left: 10,
607
+ width: 10,
608
+ height: 10,
609
+ right: 20,
610
+ bottom: 110
611
+ };
612
+ };
613
+ overflowWithin.getBoundingClientRect = function () {
614
+ return {
615
+ top: 110,
616
+ left: 10,
617
+ width: 10,
618
+ height: 10,
619
+ right: 20,
620
+ bottom: 120
621
+ };
622
+ };
623
+ overflowBelow.getBoundingClientRect = function () {
624
+ return {
625
+ top: 140,
626
+ left: 10,
627
+ width: 10,
628
+ height: 10,
629
+ right: 20,
630
+ bottom: 150
631
+ };
632
+ };
633
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', overflowWithin), function (t) {
309
634
  return t.id;
310
635
  })).toBe('overflow-below');
311
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
636
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', overflowWithin), function (t) {
312
637
  return t.id;
313
638
  })).toBe('overflow-above');
314
639
  }));
315
- test('should stop at restrict="self-only" boundaries', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
316
- (0, _container10.configureContainer)('first-container', {
317
- restrict: 'none'
318
- });
319
- (0, _container10.configureContainer)('second-container', {
320
- restrict: 'self-only'
321
- });
322
- var element = root.querySelector("[".concat(_container10.containerAttribute, "=\"second-container\"] .spottable"));
323
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
324
- return t.id;
325
- })).toBe('NOT FOUND');
326
- }));
327
640
  test('should respect enterTo="default-element" containers', (0, _utils.testScenario)(scenarios.grid, function (root) {
328
641
  (0, _container10.configureContainer)('grid', {
329
642
  restrict: 'none',
330
643
  enterTo: 'default-element',
331
644
  defaultElement: '#bottom-right'
332
645
  });
333
- var element = root.querySelector('#before-grid');
334
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
646
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
647
+ var beforeGrid = root.querySelector('#before-grid');
648
+ var afterGrid = root.querySelector('#after-grid');
649
+ var topLeft = root.querySelector('#top-left');
650
+ var topCenter = root.querySelector('#top-center');
651
+ var topRight = root.querySelector('#top-right');
652
+ var middleLeft = root.querySelector('#middle-left');
653
+ var middleCenter = root.querySelector('#middle-center');
654
+ var middleRight = root.querySelector('#middle-right');
655
+ var bottomLeft = root.querySelector('#bottom-left');
656
+ var bottomCenter = root.querySelector('#bottom-center');
657
+ var bottomRight = root.querySelector('#bottom-right');
658
+
659
+ // Mock all bounding rects
660
+ beforeGrid.getBoundingClientRect = function () {
661
+ return {
662
+ top: 0,
663
+ left: 10,
664
+ width: 30,
665
+ height: 10,
666
+ right: 40,
667
+ bottom: 10
668
+ };
669
+ };
670
+ gridContainer.getBoundingClientRect = function () {
671
+ return {
672
+ top: 10,
673
+ left: 10,
674
+ width: 30,
675
+ height: 30,
676
+ right: 40,
677
+ bottom: 40
678
+ };
679
+ };
680
+ afterGrid.getBoundingClientRect = function () {
681
+ return {
682
+ top: 40,
683
+ left: 10,
684
+ width: 30,
685
+ height: 10,
686
+ right: 40,
687
+ bottom: 50
688
+ };
689
+ };
690
+ topLeft.getBoundingClientRect = function () {
691
+ return {
692
+ top: 10,
693
+ left: 10,
694
+ width: 10,
695
+ height: 10,
696
+ right: 20,
697
+ bottom: 20
698
+ };
699
+ };
700
+ topCenter.getBoundingClientRect = function () {
701
+ return {
702
+ top: 10,
703
+ left: 20,
704
+ width: 10,
705
+ height: 10,
706
+ right: 30,
707
+ bottom: 20
708
+ };
709
+ };
710
+ topRight.getBoundingClientRect = function () {
711
+ return {
712
+ top: 10,
713
+ left: 30,
714
+ width: 10,
715
+ height: 10,
716
+ right: 40,
717
+ bottom: 20
718
+ };
719
+ };
720
+ middleLeft.getBoundingClientRect = function () {
721
+ return {
722
+ top: 20,
723
+ left: 10,
724
+ width: 10,
725
+ height: 10,
726
+ right: 20,
727
+ bottom: 30
728
+ };
729
+ };
730
+ middleCenter.getBoundingClientRect = function () {
731
+ return {
732
+ top: 20,
733
+ left: 20,
734
+ width: 10,
735
+ height: 10,
736
+ right: 30,
737
+ bottom: 30
738
+ };
739
+ };
740
+ middleRight.getBoundingClientRect = function () {
741
+ return {
742
+ top: 20,
743
+ left: 30,
744
+ width: 10,
745
+ height: 10,
746
+ right: 40,
747
+ bottom: 30
748
+ };
749
+ };
750
+ bottomLeft.getBoundingClientRect = function () {
751
+ return {
752
+ top: 30,
753
+ left: 10,
754
+ width: 10,
755
+ height: 10,
756
+ right: 20,
757
+ bottom: 40
758
+ };
759
+ };
760
+ bottomCenter.getBoundingClientRect = function () {
761
+ return {
762
+ top: 30,
763
+ left: 20,
764
+ width: 10,
765
+ height: 10,
766
+ right: 30,
767
+ bottom: 40
768
+ };
769
+ };
770
+ bottomRight.getBoundingClientRect = function () {
771
+ return {
772
+ top: 30,
773
+ left: 30,
774
+ width: 10,
775
+ height: 10,
776
+ right: 40,
777
+ bottom: 40
778
+ };
779
+ };
780
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', beforeGrid), function (t) {
335
781
  return t.id;
336
782
  })).toBe('bottom-right');
337
783
  }));
@@ -339,75 +785,716 @@ describe('target', function () {
339
785
  (0, _container10.configureContainer)('grid', {
340
786
  restrict: 'none',
341
787
  enterTo: 'last-focused',
342
- lastFocusedKey: {
343
- container: false,
344
- element: true,
345
- key: 8
346
- }
347
- });
348
- var element = root.querySelector('#before-grid');
349
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
350
- return t.id;
351
- })).toBe('bottom-right');
352
- }));
353
- test('should follow the leaveFor config when no target is found within the container in the given direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
354
- (0, _container10.configureContainer)('grid', {
355
- restrict: 'none',
356
- leaveFor: {
357
- up: '#after-grid'
358
- }
359
- });
360
- var element = root.querySelector('#top-center');
361
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
362
- return t.id;
363
- })).toBe('after-grid');
364
- }));
365
- test('should not follow the leaveFor config when a target is found within the container in the given direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
366
- (0, _container10.configureContainer)('grid', {
367
- restrict: 'none',
368
- leaveFor: {
369
- up: '#after-grid'
370
- }
371
- });
372
- var element = root.querySelector('#middle-center');
373
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
374
- return t.id;
375
- })).toBe('top-center');
376
- }));
377
- test('should not follow the leaveFor config when the selector does not match an element', (0, _utils.testScenario)(scenarios.grid, function (root) {
378
- (0, _container10.configureContainer)('grid', {
379
- restrict: 'none',
380
- leaveFor: {
381
- up: '#does-not-exist'
382
- }
788
+ lastFocusedElement: root.querySelector('#bottom-right')
383
789
  });
384
- var element = root.querySelector('#top-center');
385
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', element), function (t) {
386
- return t.id;
387
- })).toBe('before-grid');
388
- }));
389
- test('should ignore empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
390
- (0, _container10.configureContainer)('empty-container');
391
- var element = root.querySelector('#above');
392
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
393
- return t.id;
394
- })).toBe('below');
395
- }));
396
- test('should ignore overlapping empty containers', (0, _utils.testScenario)(scenarios.emptyContainerOverlap, function (root) {
397
- (0, _container10.configureContainer)('empty-container');
398
- var element = root.querySelector('#above');
399
- expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', element), function (t) {
400
- return t.id;
401
- })).toBe('below');
402
- }));
403
- });
404
- describe.skip('#getTargetByDirectionFromPosition', function () {
790
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
791
+ var beforeGrid = root.querySelector('#before-grid');
792
+ var afterGrid = root.querySelector('#after-grid');
793
+ var topLeft = root.querySelector('#top-left');
794
+ var topCenter = root.querySelector('#top-center');
795
+ var topRight = root.querySelector('#top-right');
796
+ var middleLeft = root.querySelector('#middle-left');
797
+ var middleCenter = root.querySelector('#middle-center');
798
+ var middleRight = root.querySelector('#middle-right');
799
+ var bottomLeft = root.querySelector('#bottom-left');
800
+ var bottomCenter = root.querySelector('#bottom-center');
801
+ var bottomRight = root.querySelector('#bottom-right');
802
+
803
+ // Mock all bounding rects
804
+ beforeGrid.getBoundingClientRect = function () {
805
+ return {
806
+ top: 0,
807
+ left: 10,
808
+ width: 30,
809
+ height: 10,
810
+ right: 40,
811
+ bottom: 10
812
+ };
813
+ };
814
+ gridContainer.getBoundingClientRect = function () {
815
+ return {
816
+ top: 10,
817
+ left: 10,
818
+ width: 30,
819
+ height: 30,
820
+ right: 40,
821
+ bottom: 40
822
+ };
823
+ };
824
+ afterGrid.getBoundingClientRect = function () {
825
+ return {
826
+ top: 40,
827
+ left: 10,
828
+ width: 30,
829
+ height: 10,
830
+ right: 40,
831
+ bottom: 50
832
+ };
833
+ };
834
+ topLeft.getBoundingClientRect = function () {
835
+ return {
836
+ top: 10,
837
+ left: 10,
838
+ width: 10,
839
+ height: 10,
840
+ right: 20,
841
+ bottom: 20
842
+ };
843
+ };
844
+ topCenter.getBoundingClientRect = function () {
845
+ return {
846
+ top: 10,
847
+ left: 20,
848
+ width: 10,
849
+ height: 10,
850
+ right: 30,
851
+ bottom: 20
852
+ };
853
+ };
854
+ topRight.getBoundingClientRect = function () {
855
+ return {
856
+ top: 10,
857
+ left: 30,
858
+ width: 10,
859
+ height: 10,
860
+ right: 40,
861
+ bottom: 20
862
+ };
863
+ };
864
+ middleLeft.getBoundingClientRect = function () {
865
+ return {
866
+ top: 20,
867
+ left: 10,
868
+ width: 10,
869
+ height: 10,
870
+ right: 20,
871
+ bottom: 30
872
+ };
873
+ };
874
+ middleCenter.getBoundingClientRect = function () {
875
+ return {
876
+ top: 20,
877
+ left: 20,
878
+ width: 10,
879
+ height: 10,
880
+ right: 30,
881
+ bottom: 30
882
+ };
883
+ };
884
+ middleRight.getBoundingClientRect = function () {
885
+ return {
886
+ top: 20,
887
+ left: 30,
888
+ width: 10,
889
+ height: 10,
890
+ right: 40,
891
+ bottom: 30
892
+ };
893
+ };
894
+ bottomLeft.getBoundingClientRect = function () {
895
+ return {
896
+ top: 30,
897
+ left: 10,
898
+ width: 10,
899
+ height: 10,
900
+ right: 20,
901
+ bottom: 40
902
+ };
903
+ };
904
+ bottomCenter.getBoundingClientRect = function () {
905
+ return {
906
+ top: 30,
907
+ left: 20,
908
+ width: 10,
909
+ height: 10,
910
+ right: 30,
911
+ bottom: 40
912
+ };
913
+ };
914
+ bottomRight.getBoundingClientRect = function () {
915
+ return {
916
+ top: 30,
917
+ left: 30,
918
+ width: 10,
919
+ height: 10,
920
+ right: 40,
921
+ bottom: 40
922
+ };
923
+ };
924
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', beforeGrid), function (t) {
925
+ return t.id;
926
+ })).toBe('bottom-right');
927
+ }));
928
+ test('should follow the leaveFor config when no target is found within the container in the given direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
929
+ (0, _container10.configureContainer)('grid', {
930
+ restrict: 'none',
931
+ leaveFor: {
932
+ up: '#after-grid'
933
+ }
934
+ });
935
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
936
+ var beforeGrid = root.querySelector('#before-grid');
937
+ var afterGrid = root.querySelector('#after-grid');
938
+ var topLeft = root.querySelector('#top-left');
939
+ var topCenter = root.querySelector('#top-center');
940
+ var topRight = root.querySelector('#top-right');
941
+ var middleLeft = root.querySelector('#middle-left');
942
+ var middleCenter = root.querySelector('#middle-center');
943
+ var middleRight = root.querySelector('#middle-right');
944
+ var bottomLeft = root.querySelector('#bottom-left');
945
+ var bottomCenter = root.querySelector('#bottom-center');
946
+ var bottomRight = root.querySelector('#bottom-right');
947
+
948
+ // Mock all bounding rects
949
+ beforeGrid.getBoundingClientRect = function () {
950
+ return {
951
+ top: 0,
952
+ left: 10,
953
+ width: 30,
954
+ height: 10,
955
+ right: 40,
956
+ bottom: 10
957
+ };
958
+ };
959
+ gridContainer.getBoundingClientRect = function () {
960
+ return {
961
+ top: 10,
962
+ left: 10,
963
+ width: 30,
964
+ height: 30,
965
+ right: 40,
966
+ bottom: 40
967
+ };
968
+ };
969
+ afterGrid.getBoundingClientRect = function () {
970
+ return {
971
+ top: 40,
972
+ left: 10,
973
+ width: 30,
974
+ height: 10,
975
+ right: 40,
976
+ bottom: 50
977
+ };
978
+ };
979
+ topLeft.getBoundingClientRect = function () {
980
+ return {
981
+ top: 10,
982
+ left: 10,
983
+ width: 10,
984
+ height: 10,
985
+ right: 20,
986
+ bottom: 20
987
+ };
988
+ };
989
+ topCenter.getBoundingClientRect = function () {
990
+ return {
991
+ top: 10,
992
+ left: 20,
993
+ width: 10,
994
+ height: 10,
995
+ right: 30,
996
+ bottom: 20
997
+ };
998
+ };
999
+ topRight.getBoundingClientRect = function () {
1000
+ return {
1001
+ top: 10,
1002
+ left: 30,
1003
+ width: 10,
1004
+ height: 10,
1005
+ right: 40,
1006
+ bottom: 20
1007
+ };
1008
+ };
1009
+ middleLeft.getBoundingClientRect = function () {
1010
+ return {
1011
+ top: 20,
1012
+ left: 10,
1013
+ width: 10,
1014
+ height: 10,
1015
+ right: 20,
1016
+ bottom: 30
1017
+ };
1018
+ };
1019
+ middleCenter.getBoundingClientRect = function () {
1020
+ return {
1021
+ top: 20,
1022
+ left: 20,
1023
+ width: 10,
1024
+ height: 10,
1025
+ right: 30,
1026
+ bottom: 30
1027
+ };
1028
+ };
1029
+ middleRight.getBoundingClientRect = function () {
1030
+ return {
1031
+ top: 20,
1032
+ left: 30,
1033
+ width: 10,
1034
+ height: 10,
1035
+ right: 40,
1036
+ bottom: 30
1037
+ };
1038
+ };
1039
+ bottomLeft.getBoundingClientRect = function () {
1040
+ return {
1041
+ top: 30,
1042
+ left: 10,
1043
+ width: 10,
1044
+ height: 10,
1045
+ right: 20,
1046
+ bottom: 40
1047
+ };
1048
+ };
1049
+ bottomCenter.getBoundingClientRect = function () {
1050
+ return {
1051
+ top: 30,
1052
+ left: 20,
1053
+ width: 10,
1054
+ height: 10,
1055
+ right: 30,
1056
+ bottom: 40
1057
+ };
1058
+ };
1059
+ bottomRight.getBoundingClientRect = function () {
1060
+ return {
1061
+ top: 30,
1062
+ left: 30,
1063
+ width: 10,
1064
+ height: 10,
1065
+ right: 40,
1066
+ bottom: 40
1067
+ };
1068
+ };
1069
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', topCenter), function (t) {
1070
+ return t.id;
1071
+ })).toBe('after-grid');
1072
+ }));
1073
+ test('should not follow the leaveFor config when a target is found within the container in the given direction', (0, _utils.testScenario)(scenarios.grid, function (root) {
1074
+ (0, _container10.configureContainer)('grid', {
1075
+ restrict: 'none',
1076
+ leaveFor: {
1077
+ up: '#after-grid'
1078
+ }
1079
+ });
1080
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
1081
+ var beforeGrid = root.querySelector('#before-grid');
1082
+ var afterGrid = root.querySelector('#after-grid');
1083
+ var topLeft = root.querySelector('#top-left');
1084
+ var topCenter = root.querySelector('#top-center');
1085
+ var topRight = root.querySelector('#top-right');
1086
+ var middleLeft = root.querySelector('#middle-left');
1087
+ var middleCenter = root.querySelector('#middle-center');
1088
+ var middleRight = root.querySelector('#middle-right');
1089
+ var bottomLeft = root.querySelector('#bottom-left');
1090
+ var bottomCenter = root.querySelector('#bottom-center');
1091
+ var bottomRight = root.querySelector('#bottom-right');
1092
+
1093
+ // Mock all bounding rects
1094
+ beforeGrid.getBoundingClientRect = function () {
1095
+ return {
1096
+ top: 0,
1097
+ left: 10,
1098
+ width: 30,
1099
+ height: 10,
1100
+ right: 40,
1101
+ bottom: 10
1102
+ };
1103
+ };
1104
+ gridContainer.getBoundingClientRect = function () {
1105
+ return {
1106
+ top: 10,
1107
+ left: 10,
1108
+ width: 30,
1109
+ height: 30,
1110
+ right: 40,
1111
+ bottom: 40
1112
+ };
1113
+ };
1114
+ afterGrid.getBoundingClientRect = function () {
1115
+ return {
1116
+ top: 40,
1117
+ left: 10,
1118
+ width: 30,
1119
+ height: 10,
1120
+ right: 40,
1121
+ bottom: 50
1122
+ };
1123
+ };
1124
+ topLeft.getBoundingClientRect = function () {
1125
+ return {
1126
+ top: 10,
1127
+ left: 10,
1128
+ width: 10,
1129
+ height: 10,
1130
+ right: 20,
1131
+ bottom: 20
1132
+ };
1133
+ };
1134
+ topCenter.getBoundingClientRect = function () {
1135
+ return {
1136
+ top: 10,
1137
+ left: 20,
1138
+ width: 10,
1139
+ height: 10,
1140
+ right: 30,
1141
+ bottom: 20
1142
+ };
1143
+ };
1144
+ topRight.getBoundingClientRect = function () {
1145
+ return {
1146
+ top: 10,
1147
+ left: 30,
1148
+ width: 10,
1149
+ height: 10,
1150
+ right: 40,
1151
+ bottom: 20
1152
+ };
1153
+ };
1154
+ middleLeft.getBoundingClientRect = function () {
1155
+ return {
1156
+ top: 20,
1157
+ left: 10,
1158
+ width: 10,
1159
+ height: 10,
1160
+ right: 20,
1161
+ bottom: 30
1162
+ };
1163
+ };
1164
+ middleCenter.getBoundingClientRect = function () {
1165
+ return {
1166
+ top: 20,
1167
+ left: 20,
1168
+ width: 10,
1169
+ height: 10,
1170
+ right: 30,
1171
+ bottom: 30
1172
+ };
1173
+ };
1174
+ middleRight.getBoundingClientRect = function () {
1175
+ return {
1176
+ top: 20,
1177
+ left: 30,
1178
+ width: 10,
1179
+ height: 10,
1180
+ right: 40,
1181
+ bottom: 30
1182
+ };
1183
+ };
1184
+ bottomLeft.getBoundingClientRect = function () {
1185
+ return {
1186
+ top: 30,
1187
+ left: 10,
1188
+ width: 10,
1189
+ height: 10,
1190
+ right: 20,
1191
+ bottom: 40
1192
+ };
1193
+ };
1194
+ bottomCenter.getBoundingClientRect = function () {
1195
+ return {
1196
+ top: 30,
1197
+ left: 20,
1198
+ width: 10,
1199
+ height: 10,
1200
+ right: 30,
1201
+ bottom: 40
1202
+ };
1203
+ };
1204
+ bottomRight.getBoundingClientRect = function () {
1205
+ return {
1206
+ top: 30,
1207
+ left: 30,
1208
+ width: 10,
1209
+ height: 10,
1210
+ right: 40,
1211
+ bottom: 40
1212
+ };
1213
+ };
1214
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', middleCenter), function (t) {
1215
+ return t.id;
1216
+ })).toBe('top-center');
1217
+ }));
1218
+ test('should not follow the leaveFor config when the selector does not match an element', (0, _utils.testScenario)(scenarios.grid, function (root) {
1219
+ (0, _container10.configureContainer)('grid', {
1220
+ restrict: 'none',
1221
+ leaveFor: {
1222
+ up: '#does-not-exist'
1223
+ }
1224
+ });
1225
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
1226
+ var beforeGrid = root.querySelector('#before-grid');
1227
+ var afterGrid = root.querySelector('#after-grid');
1228
+ var topLeft = root.querySelector('#top-left');
1229
+ var topCenter = root.querySelector('#top-center');
1230
+ var topRight = root.querySelector('#top-right');
1231
+ var middleLeft = root.querySelector('#middle-left');
1232
+ var middleCenter = root.querySelector('#middle-center');
1233
+ var middleRight = root.querySelector('#middle-right');
1234
+ var bottomLeft = root.querySelector('#bottom-left');
1235
+ var bottomCenter = root.querySelector('#bottom-center');
1236
+ var bottomRight = root.querySelector('#bottom-right');
1237
+
1238
+ // Mock all bounding rects
1239
+ beforeGrid.getBoundingClientRect = function () {
1240
+ return {
1241
+ top: 0,
1242
+ left: 10,
1243
+ width: 30,
1244
+ height: 10,
1245
+ right: 40,
1246
+ bottom: 10
1247
+ };
1248
+ };
1249
+ gridContainer.getBoundingClientRect = function () {
1250
+ return {
1251
+ top: 10,
1252
+ left: 10,
1253
+ width: 30,
1254
+ height: 30,
1255
+ right: 40,
1256
+ bottom: 40
1257
+ };
1258
+ };
1259
+ afterGrid.getBoundingClientRect = function () {
1260
+ return {
1261
+ top: 40,
1262
+ left: 10,
1263
+ width: 30,
1264
+ height: 10,
1265
+ right: 40,
1266
+ bottom: 50
1267
+ };
1268
+ };
1269
+ topLeft.getBoundingClientRect = function () {
1270
+ return {
1271
+ top: 10,
1272
+ left: 10,
1273
+ width: 10,
1274
+ height: 10,
1275
+ right: 20,
1276
+ bottom: 20
1277
+ };
1278
+ };
1279
+ topCenter.getBoundingClientRect = function () {
1280
+ return {
1281
+ top: 10,
1282
+ left: 20,
1283
+ width: 10,
1284
+ height: 10,
1285
+ right: 30,
1286
+ bottom: 20
1287
+ };
1288
+ };
1289
+ topRight.getBoundingClientRect = function () {
1290
+ return {
1291
+ top: 10,
1292
+ left: 30,
1293
+ width: 10,
1294
+ height: 10,
1295
+ right: 40,
1296
+ bottom: 20
1297
+ };
1298
+ };
1299
+ middleLeft.getBoundingClientRect = function () {
1300
+ return {
1301
+ top: 20,
1302
+ left: 10,
1303
+ width: 10,
1304
+ height: 10,
1305
+ right: 20,
1306
+ bottom: 30
1307
+ };
1308
+ };
1309
+ middleCenter.getBoundingClientRect = function () {
1310
+ return {
1311
+ top: 20,
1312
+ left: 20,
1313
+ width: 10,
1314
+ height: 10,
1315
+ right: 30,
1316
+ bottom: 30
1317
+ };
1318
+ };
1319
+ middleRight.getBoundingClientRect = function () {
1320
+ return {
1321
+ top: 20,
1322
+ left: 30,
1323
+ width: 10,
1324
+ height: 10,
1325
+ right: 40,
1326
+ bottom: 30
1327
+ };
1328
+ };
1329
+ bottomLeft.getBoundingClientRect = function () {
1330
+ return {
1331
+ top: 30,
1332
+ left: 10,
1333
+ width: 10,
1334
+ height: 10,
1335
+ right: 20,
1336
+ bottom: 40
1337
+ };
1338
+ };
1339
+ bottomCenter.getBoundingClientRect = function () {
1340
+ return {
1341
+ top: 30,
1342
+ left: 20,
1343
+ width: 10,
1344
+ height: 10,
1345
+ right: 30,
1346
+ bottom: 40
1347
+ };
1348
+ };
1349
+ bottomRight.getBoundingClientRect = function () {
1350
+ return {
1351
+ top: 30,
1352
+ left: 30,
1353
+ width: 10,
1354
+ height: 10,
1355
+ right: 40,
1356
+ bottom: 40
1357
+ };
1358
+ };
1359
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('up', topCenter), function (t) {
1360
+ return t.id;
1361
+ })).toBe('before-grid');
1362
+ }));
1363
+ test('should ignore empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
1364
+ (0, _container10.configureContainer)('empty-container');
1365
+ var emptyContainer = root.querySelector('[data-spotlight-id="empty-container"]');
1366
+ var above = root.querySelector('#above');
1367
+ var below = root.querySelector('#below');
1368
+
1369
+ // Mock all bounding rects
1370
+ above.getBoundingClientRect = function () {
1371
+ return {
1372
+ top: 0,
1373
+ left: 10,
1374
+ width: 10,
1375
+ height: 10,
1376
+ right: 20,
1377
+ bottom: 10
1378
+ };
1379
+ };
1380
+ emptyContainer.getBoundingClientRect = function () {
1381
+ return {
1382
+ top: 10,
1383
+ left: 10,
1384
+ width: 10,
1385
+ height: 10,
1386
+ right: 20,
1387
+ bottom: 20
1388
+ };
1389
+ };
1390
+ below.getBoundingClientRect = function () {
1391
+ return {
1392
+ top: 30,
1393
+ left: 0,
1394
+ width: 10,
1395
+ height: 10,
1396
+ right: 10,
1397
+ bottom: 40
1398
+ };
1399
+ };
1400
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', above), function (t) {
1401
+ return t.id;
1402
+ })).toBe('below');
1403
+ }));
1404
+ test('should ignore overlapping empty containers', (0, _utils.testScenario)(scenarios.emptyContainerOverlap, function (root) {
1405
+ (0, _container10.configureContainer)('empty-container');
1406
+ var emptyContainer = root.querySelector('[data-spotlight-id="empty-container"]');
1407
+ var above = root.querySelector('#above');
1408
+ var below = root.querySelector('#below');
1409
+
1410
+ // Mock all bounding rects
1411
+ above.getBoundingClientRect = function () {
1412
+ return {
1413
+ top: 5,
1414
+ left: 10,
1415
+ width: 10,
1416
+ height: 10,
1417
+ right: 20,
1418
+ bottom: 15
1419
+ };
1420
+ };
1421
+ emptyContainer.getBoundingClientRect = function () {
1422
+ return {
1423
+ top: 10,
1424
+ left: 10,
1425
+ width: 10,
1426
+ height: 10,
1427
+ right: 20,
1428
+ bottom: 20
1429
+ };
1430
+ };
1431
+ below.getBoundingClientRect = function () {
1432
+ return {
1433
+ top: 30,
1434
+ left: 0,
1435
+ width: 10,
1436
+ height: 10,
1437
+ right: 10,
1438
+ bottom: 40
1439
+ };
1440
+ };
1441
+ expect(safeTarget((0, _target.getTargetByDirectionFromElement)('down', above), function (t) {
1442
+ return t.id;
1443
+ })).toBe('below');
1444
+ }));
1445
+ });
1446
+ describe('#getTargetByDirectionFromPosition', function () {
405
1447
  test('should find target within container', (0, _utils.testScenario)(scenarios.grid, function (root) {
406
1448
  (0, _container10.configureContainer)('grid');
407
- var rect = root.querySelector('#middle-center').getBoundingClientRect();
1449
+ var middleCenter = root.querySelector('#middle-center');
1450
+ var topCenter = root.querySelector('#top-center');
1451
+ var bottomCenter = root.querySelector('#bottom-center');
1452
+ var middleLeft = root.querySelector('#middle-left');
1453
+ var middleRight = root.querySelector('#middle-right');
1454
+ middleCenter.getBoundingClientRect = function () {
1455
+ return {
1456
+ top: 10,
1457
+ left: 10,
1458
+ width: 10,
1459
+ height: 10
1460
+ };
1461
+ };
1462
+ topCenter.getBoundingClientRect = function () {
1463
+ return {
1464
+ top: 0,
1465
+ left: 10,
1466
+ width: 10,
1467
+ height: 10
1468
+ };
1469
+ };
1470
+ bottomCenter.getBoundingClientRect = function () {
1471
+ return {
1472
+ top: 20,
1473
+ left: 10,
1474
+ width: 10,
1475
+ height: 10
1476
+ };
1477
+ };
1478
+ middleLeft.getBoundingClientRect = function () {
1479
+ return {
1480
+ top: 10,
1481
+ left: 0,
1482
+ width: 10,
1483
+ height: 10
1484
+ };
1485
+ };
1486
+ middleRight.getBoundingClientRect = function () {
1487
+ return {
1488
+ top: 10,
1489
+ left: 20,
1490
+ width: 10,
1491
+ height: 10
1492
+ };
1493
+ };
1494
+ var centerRect = root.querySelector('#middle-center').getBoundingClientRect();
408
1495
  var center = {
409
- x: rect.left + rect.width / 2,
410
- y: rect.top + rect.height / 2
1496
+ x: centerRect.left + centerRect.width / 2,
1497
+ y: centerRect.top + centerRect.height / 2
411
1498
  };
412
1499
  expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', center, 'grid'), function (t) {
413
1500
  return t.id;
@@ -422,37 +1509,292 @@ describe('target', function () {
422
1509
  return t.id;
423
1510
  })).toBe('middle-right');
424
1511
  }));
425
- test('should not find a target when at bounds of container with restrict="self-only"', (0, _utils.testScenario)(scenarios.grid, function (root) {
1512
+ test('should keep the same target when at bounds of container with restrict="self-only"', (0, _utils.testScenario)(scenarios.grid, function (root) {
426
1513
  (0, _container10.configureContainer)('grid', {
427
1514
  restrict: 'self-only'
428
1515
  });
1516
+ var topCenter = root.querySelector('#top-center');
1517
+ topCenter.getBoundingClientRect = function () {
1518
+ return {
1519
+ top: 0,
1520
+ left: 10,
1521
+ width: 10,
1522
+ height: 10
1523
+ };
1524
+ };
429
1525
  var rect = root.querySelector('#top-center').getBoundingClientRect();
430
1526
  var topCenterOfGrid = {
431
1527
  x: rect.left + rect.width / 2,
432
1528
  y: rect.top
433
1529
  };
434
- expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', topCenterOfGrid, 'grid'), function (t) {
435
- return t.id;
436
- })).toBe('NOT FOUND');
437
- }));
438
- test('should not find a target outside of container when restrict is not set', (0, _utils.testScenario)(scenarios.grid, function (root) {
439
- (0, _container10.configureContainer)('grid', {
440
- restrict: 'none'
441
- });
442
- var rect = root.querySelector('#top-center').getBoundingClientRect();
443
- var topCenterOfGrid = {
444
- x: rect.left + rect.width / 2,
445
- y: rect.top
1530
+ expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', topCenterOfGrid, 'grid'), function (t) {
1531
+ return t.id;
1532
+ })).toBe('top-left');
1533
+ }));
1534
+ test('should not find a target outside of container when restrict is not set', (0, _utils.testScenario)(scenarios.grid, function (root) {
1535
+ (0, _container10.configureContainer)('grid', {
1536
+ restrict: 'none'
1537
+ });
1538
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
1539
+ var beforeGrid = root.querySelector('#before-grid');
1540
+ var topLeft = root.querySelector('#top-left');
1541
+ var topCenter = root.querySelector('#top-center');
1542
+ var topRight = root.querySelector('#top-right');
1543
+ var middleLeft = root.querySelector('#middle-left');
1544
+ var middleCenter = root.querySelector('#middle-center');
1545
+ var middleRight = root.querySelector('#middle-right');
1546
+ var bottomLeft = root.querySelector('#bottom-left');
1547
+ var bottomCenter = root.querySelector('#bottom-center');
1548
+ var bottomRight = root.querySelector('#bottom-right');
1549
+
1550
+ // Mock all bounding rects
1551
+ beforeGrid.getBoundingClientRect = function () {
1552
+ return {
1553
+ top: 0,
1554
+ left: 10,
1555
+ width: 30,
1556
+ height: 10,
1557
+ right: 40,
1558
+ bottom: 10
1559
+ };
1560
+ };
1561
+ gridContainer.getBoundingClientRect = function () {
1562
+ return {
1563
+ top: 10,
1564
+ left: 10,
1565
+ width: 30,
1566
+ height: 30,
1567
+ right: 40,
1568
+ bottom: 40
1569
+ };
1570
+ };
1571
+ topLeft.getBoundingClientRect = function () {
1572
+ return {
1573
+ top: 10,
1574
+ left: 10,
1575
+ width: 10,
1576
+ height: 10,
1577
+ right: 20,
1578
+ bottom: 20
1579
+ };
1580
+ };
1581
+ topCenter.getBoundingClientRect = function () {
1582
+ return {
1583
+ top: 10,
1584
+ left: 20,
1585
+ width: 10,
1586
+ height: 10,
1587
+ right: 30,
1588
+ bottom: 20
1589
+ };
1590
+ };
1591
+ topRight.getBoundingClientRect = function () {
1592
+ return {
1593
+ top: 10,
1594
+ left: 30,
1595
+ width: 10,
1596
+ height: 10,
1597
+ right: 40,
1598
+ bottom: 20
1599
+ };
1600
+ };
1601
+ middleLeft.getBoundingClientRect = function () {
1602
+ return {
1603
+ top: 20,
1604
+ left: 10,
1605
+ width: 10,
1606
+ height: 10,
1607
+ right: 20,
1608
+ bottom: 30
1609
+ };
1610
+ };
1611
+ middleCenter.getBoundingClientRect = function () {
1612
+ return {
1613
+ top: 20,
1614
+ left: 20,
1615
+ width: 10,
1616
+ height: 10,
1617
+ right: 30,
1618
+ bottom: 30
1619
+ };
1620
+ };
1621
+ middleRight.getBoundingClientRect = function () {
1622
+ return {
1623
+ top: 20,
1624
+ left: 30,
1625
+ width: 10,
1626
+ height: 10,
1627
+ right: 40,
1628
+ bottom: 30
1629
+ };
1630
+ };
1631
+ bottomLeft.getBoundingClientRect = function () {
1632
+ return {
1633
+ top: 30,
1634
+ left: 10,
1635
+ width: 10,
1636
+ height: 10,
1637
+ right: 20,
1638
+ bottom: 40
1639
+ };
1640
+ };
1641
+ bottomCenter.getBoundingClientRect = function () {
1642
+ return {
1643
+ top: 30,
1644
+ left: 20,
1645
+ width: 10,
1646
+ height: 10,
1647
+ right: 30,
1648
+ bottom: 40
1649
+ };
1650
+ };
1651
+ bottomRight.getBoundingClientRect = function () {
1652
+ return {
1653
+ top: 30,
1654
+ left: 30,
1655
+ width: 10,
1656
+ height: 10,
1657
+ right: 40,
1658
+ bottom: 40
1659
+ };
1660
+ };
1661
+ var rect = topCenter.getBoundingClientRect();
1662
+ var topCenterOfGrid = {
1663
+ x: rect.left + rect.width / 2,
1664
+ y: rect.top
1665
+ };
1666
+ expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', topCenterOfGrid, 'grid'), function (t) {
1667
+ return t.id;
1668
+ })).toBe('before-grid');
1669
+ }));
1670
+ test('should cascade into unrestricted subcontainers', (0, _utils.testScenario)(scenarios.grid, function (root) {
1671
+ (0, _container10.configureContainer)('grid', {
1672
+ restrict: 'none'
1673
+ });
1674
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
1675
+ var beforeGrid = root.querySelector('#before-grid');
1676
+ var topLeft = root.querySelector('#top-left');
1677
+ var topCenter = root.querySelector('#top-center');
1678
+ var topRight = root.querySelector('#top-right');
1679
+ var middleLeft = root.querySelector('#middle-left');
1680
+ var middleCenter = root.querySelector('#middle-center');
1681
+ var middleRight = root.querySelector('#middle-right');
1682
+ var bottomLeft = root.querySelector('#bottom-left');
1683
+ var bottomCenter = root.querySelector('#bottom-center');
1684
+ var bottomRight = root.querySelector('#bottom-right');
1685
+
1686
+ // Mock all bounding rects
1687
+ beforeGrid.getBoundingClientRect = function () {
1688
+ return {
1689
+ top: 0,
1690
+ left: 10,
1691
+ width: 30,
1692
+ height: 10,
1693
+ right: 40,
1694
+ bottom: 10
1695
+ };
1696
+ };
1697
+ gridContainer.getBoundingClientRect = function () {
1698
+ return {
1699
+ top: 10,
1700
+ left: 10,
1701
+ width: 30,
1702
+ height: 30,
1703
+ right: 40,
1704
+ bottom: 40
1705
+ };
1706
+ };
1707
+ topLeft.getBoundingClientRect = function () {
1708
+ return {
1709
+ top: 10,
1710
+ left: 10,
1711
+ width: 10,
1712
+ height: 10,
1713
+ right: 20,
1714
+ bottom: 20
1715
+ };
1716
+ };
1717
+ topCenter.getBoundingClientRect = function () {
1718
+ return {
1719
+ top: 10,
1720
+ left: 20,
1721
+ width: 10,
1722
+ height: 10,
1723
+ right: 30,
1724
+ bottom: 20
1725
+ };
1726
+ };
1727
+ topRight.getBoundingClientRect = function () {
1728
+ return {
1729
+ top: 10,
1730
+ left: 30,
1731
+ width: 10,
1732
+ height: 10,
1733
+ right: 40,
1734
+ bottom: 20
1735
+ };
1736
+ };
1737
+ middleLeft.getBoundingClientRect = function () {
1738
+ return {
1739
+ top: 20,
1740
+ left: 10,
1741
+ width: 10,
1742
+ height: 10,
1743
+ right: 20,
1744
+ bottom: 30
1745
+ };
1746
+ };
1747
+ middleCenter.getBoundingClientRect = function () {
1748
+ return {
1749
+ top: 20,
1750
+ left: 20,
1751
+ width: 10,
1752
+ height: 10,
1753
+ right: 30,
1754
+ bottom: 30
1755
+ };
446
1756
  };
447
- expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('up', topCenterOfGrid, 'grid'), function (t) {
448
- return t.id;
449
- })).toBe('before-grid');
450
- }));
451
- test('should cascade into unrestricted subcontainers', (0, _utils.testScenario)(scenarios.grid, function (root) {
452
- (0, _container10.configureContainer)('grid', {
453
- restrict: 'none'
454
- });
455
- var rect = root.querySelector('#top-center').getBoundingClientRect();
1757
+ middleRight.getBoundingClientRect = function () {
1758
+ return {
1759
+ top: 20,
1760
+ left: 30,
1761
+ width: 10,
1762
+ height: 10,
1763
+ right: 40,
1764
+ bottom: 30
1765
+ };
1766
+ };
1767
+ bottomLeft.getBoundingClientRect = function () {
1768
+ return {
1769
+ top: 30,
1770
+ left: 10,
1771
+ width: 10,
1772
+ height: 10,
1773
+ right: 20,
1774
+ bottom: 40
1775
+ };
1776
+ };
1777
+ bottomCenter.getBoundingClientRect = function () {
1778
+ return {
1779
+ top: 30,
1780
+ left: 20,
1781
+ width: 10,
1782
+ height: 10,
1783
+ right: 30,
1784
+ bottom: 40
1785
+ };
1786
+ };
1787
+ bottomRight.getBoundingClientRect = function () {
1788
+ return {
1789
+ top: 30,
1790
+ left: 30,
1791
+ width: 10,
1792
+ height: 10,
1793
+ right: 40,
1794
+ bottom: 40
1795
+ };
1796
+ };
1797
+ var rect = topCenter.getBoundingClientRect();
456
1798
  var aboveCenterOfGrid = {
457
1799
  x: rect.left + rect.width / 2,
458
1800
  y: rect.top - 1
@@ -467,7 +1809,130 @@ describe('target', function () {
467
1809
  enterTo: 'default-element',
468
1810
  defaultElement: '#bottom-right'
469
1811
  });
470
- var rect = root.querySelector('#top-center').getBoundingClientRect();
1812
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
1813
+ var beforeGrid = root.querySelector('#before-grid');
1814
+ var topLeft = root.querySelector('#top-left');
1815
+ var topCenter = root.querySelector('#top-center');
1816
+ var topRight = root.querySelector('#top-right');
1817
+ var middleLeft = root.querySelector('#middle-left');
1818
+ var middleCenter = root.querySelector('#middle-center');
1819
+ var middleRight = root.querySelector('#middle-right');
1820
+ var bottomLeft = root.querySelector('#bottom-left');
1821
+ var bottomCenter = root.querySelector('#bottom-center');
1822
+ var bottomRight = root.querySelector('#bottom-right');
1823
+
1824
+ // Mock all bounding rects
1825
+ beforeGrid.getBoundingClientRect = function () {
1826
+ return {
1827
+ top: 0,
1828
+ left: 10,
1829
+ width: 30,
1830
+ height: 10,
1831
+ right: 40,
1832
+ bottom: 10
1833
+ };
1834
+ };
1835
+ gridContainer.getBoundingClientRect = function () {
1836
+ return {
1837
+ top: 10,
1838
+ left: 10,
1839
+ width: 30,
1840
+ height: 30,
1841
+ right: 40,
1842
+ bottom: 40
1843
+ };
1844
+ };
1845
+ topLeft.getBoundingClientRect = function () {
1846
+ return {
1847
+ top: 10,
1848
+ left: 10,
1849
+ width: 10,
1850
+ height: 10,
1851
+ right: 20,
1852
+ bottom: 20
1853
+ };
1854
+ };
1855
+ topCenter.getBoundingClientRect = function () {
1856
+ return {
1857
+ top: 10,
1858
+ left: 20,
1859
+ width: 10,
1860
+ height: 10,
1861
+ right: 30,
1862
+ bottom: 20
1863
+ };
1864
+ };
1865
+ topRight.getBoundingClientRect = function () {
1866
+ return {
1867
+ top: 10,
1868
+ left: 30,
1869
+ width: 10,
1870
+ height: 10,
1871
+ right: 40,
1872
+ bottom: 20
1873
+ };
1874
+ };
1875
+ middleLeft.getBoundingClientRect = function () {
1876
+ return {
1877
+ top: 20,
1878
+ left: 10,
1879
+ width: 10,
1880
+ height: 10,
1881
+ right: 20,
1882
+ bottom: 30
1883
+ };
1884
+ };
1885
+ middleCenter.getBoundingClientRect = function () {
1886
+ return {
1887
+ top: 20,
1888
+ left: 20,
1889
+ width: 10,
1890
+ height: 10,
1891
+ right: 30,
1892
+ bottom: 30
1893
+ };
1894
+ };
1895
+ middleRight.getBoundingClientRect = function () {
1896
+ return {
1897
+ top: 20,
1898
+ left: 30,
1899
+ width: 10,
1900
+ height: 10,
1901
+ right: 40,
1902
+ bottom: 30
1903
+ };
1904
+ };
1905
+ bottomLeft.getBoundingClientRect = function () {
1906
+ return {
1907
+ top: 30,
1908
+ left: 10,
1909
+ width: 10,
1910
+ height: 10,
1911
+ right: 20,
1912
+ bottom: 40
1913
+ };
1914
+ };
1915
+ bottomCenter.getBoundingClientRect = function () {
1916
+ return {
1917
+ top: 30,
1918
+ left: 20,
1919
+ width: 10,
1920
+ height: 10,
1921
+ right: 30,
1922
+ bottom: 40
1923
+ };
1924
+ };
1925
+ bottomRight.getBoundingClientRect = function () {
1926
+ return {
1927
+ top: 30,
1928
+ left: 30,
1929
+ width: 10,
1930
+ height: 10,
1931
+ right: 40,
1932
+ bottom: 40
1933
+ };
1934
+ };
1935
+ var rect = topCenter.getBoundingClientRect();
471
1936
  var aboveCenterOfGrid = {
472
1937
  x: rect.left + rect.width / 2,
473
1938
  y: rect.top - 1
@@ -481,7 +1946,130 @@ describe('target', function () {
481
1946
  enterTo: 'default-element',
482
1947
  defaultElement: '#bottom-right'
483
1948
  });
1949
+ var gridContainer = root.querySelector('[data-spotlight-id="grid"]');
484
1950
  var overlap = root.querySelector('#over-middle-center');
1951
+ var topLeft = root.querySelector('#top-left');
1952
+ var topCenter = root.querySelector('#top-center');
1953
+ var topRight = root.querySelector('#top-right');
1954
+ var middleLeft = root.querySelector('#middle-left');
1955
+ var middleCenter = root.querySelector('#middle-center');
1956
+ var middleRight = root.querySelector('#middle-right');
1957
+ var bottomLeft = root.querySelector('#bottom-left');
1958
+ var bottomCenter = root.querySelector('#bottom-center');
1959
+ var bottomRight = root.querySelector('#bottom-right');
1960
+
1961
+ // Mock all bounding rects
1962
+ gridContainer.getBoundingClientRect = function () {
1963
+ return {
1964
+ top: 10,
1965
+ left: 10,
1966
+ width: 30,
1967
+ height: 30,
1968
+ right: 40,
1969
+ bottom: 40
1970
+ };
1971
+ };
1972
+ topLeft.getBoundingClientRect = function () {
1973
+ return {
1974
+ top: 10,
1975
+ left: 10,
1976
+ width: 10,
1977
+ height: 10,
1978
+ right: 20,
1979
+ bottom: 20
1980
+ };
1981
+ };
1982
+ topCenter.getBoundingClientRect = function () {
1983
+ return {
1984
+ top: 10,
1985
+ left: 20,
1986
+ width: 10,
1987
+ height: 10,
1988
+ right: 30,
1989
+ bottom: 20
1990
+ };
1991
+ };
1992
+ topRight.getBoundingClientRect = function () {
1993
+ return {
1994
+ top: 10,
1995
+ left: 30,
1996
+ width: 10,
1997
+ height: 10,
1998
+ right: 40,
1999
+ bottom: 20
2000
+ };
2001
+ };
2002
+ middleLeft.getBoundingClientRect = function () {
2003
+ return {
2004
+ top: 20,
2005
+ left: 10,
2006
+ width: 10,
2007
+ height: 10,
2008
+ right: 20,
2009
+ bottom: 30
2010
+ };
2011
+ };
2012
+ middleCenter.getBoundingClientRect = function () {
2013
+ return {
2014
+ top: 20,
2015
+ left: 20,
2016
+ width: 10,
2017
+ height: 10,
2018
+ right: 30,
2019
+ bottom: 30
2020
+ };
2021
+ };
2022
+ middleRight.getBoundingClientRect = function () {
2023
+ return {
2024
+ top: 20,
2025
+ left: 30,
2026
+ width: 10,
2027
+ height: 10,
2028
+ right: 40,
2029
+ bottom: 30
2030
+ };
2031
+ };
2032
+ bottomLeft.getBoundingClientRect = function () {
2033
+ return {
2034
+ top: 30,
2035
+ left: 10,
2036
+ width: 10,
2037
+ height: 10,
2038
+ right: 20,
2039
+ bottom: 40
2040
+ };
2041
+ };
2042
+ bottomCenter.getBoundingClientRect = function () {
2043
+ return {
2044
+ top: 30,
2045
+ left: 20,
2046
+ width: 10,
2047
+ height: 10,
2048
+ right: 30,
2049
+ bottom: 40
2050
+ };
2051
+ };
2052
+ bottomRight.getBoundingClientRect = function () {
2053
+ return {
2054
+ top: 30,
2055
+ left: 30,
2056
+ width: 10,
2057
+ height: 10,
2058
+ right: 40,
2059
+ bottom: 40
2060
+ };
2061
+ };
2062
+ // Overlap is floating over middle-center
2063
+ overlap.getBoundingClientRect = function () {
2064
+ return {
2065
+ top: 22,
2066
+ left: 25,
2067
+ width: 1,
2068
+ height: 1,
2069
+ right: 26,
2070
+ bottom: 23
2071
+ };
2072
+ };
485
2073
  var _overlap$getBoundingC = overlap.getBoundingClientRect(),
486
2074
  x = _overlap$getBoundingC.left,
487
2075
  y = _overlap$getBoundingC.top;
@@ -496,14 +2084,72 @@ describe('target', function () {
496
2084
  (0, _container10.configureContainer)('overflow-container', {
497
2085
  overflow: true
498
2086
  });
2087
+ var overflowContainer = root.querySelector('[data-spotlight-id="overflow-container"]');
499
2088
  var element = root.querySelector('#outside-overflow');
2089
+ var overflowAbove = root.querySelector('#overflow-above');
2090
+ var overflowBelow = root.querySelector('#overflow-below');
2091
+ var overflowWithin = root.querySelector('#overflow-within');
2092
+
2093
+ // Mock all bounding rects
2094
+ overflowContainer.getBoundingClientRect = function () {
2095
+ return {
2096
+ top: 50,
2097
+ left: 10,
2098
+ width: 30,
2099
+ height: 30,
2100
+ right: 40,
2101
+ bottom: 80
2102
+ };
2103
+ };
2104
+ element.getBoundingClientRect = function () {
2105
+ return {
2106
+ top: 10,
2107
+ left: 10,
2108
+ width: 10,
2109
+ height: 10,
2110
+ right: 20,
2111
+ bottom: 20
2112
+ };
2113
+ };
2114
+ overflowAbove.getBoundingClientRect = function () {
2115
+ return {
2116
+ top: 30,
2117
+ left: 10,
2118
+ width: 10,
2119
+ height: 10,
2120
+ right: 20,
2121
+ bottom: 40
2122
+ };
2123
+ };
2124
+ overflowWithin.getBoundingClientRect = function () {
2125
+ return {
2126
+ top: 55,
2127
+ left: 10,
2128
+ width: 10,
2129
+ height: 10,
2130
+ right: 20,
2131
+ bottom: 65
2132
+ };
2133
+ };
2134
+ overflowBelow.getBoundingClientRect = function () {
2135
+ return {
2136
+ top: 85,
2137
+ left: 10,
2138
+ width: 10,
2139
+ height: 10,
2140
+ right: 20,
2141
+ bottom: 95
2142
+ };
2143
+ };
500
2144
  var _element$getBoundingC = element.getBoundingClientRect(),
501
2145
  x = _element$getBoundingC.left,
502
2146
  y = _element$getBoundingC.top;
503
2147
  expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', {
504
- x: x,
505
- y: y
506
- }, _container10.rootContainerId), function (t) {
2148
+ x: x + 15,
2149
+ y: y + 35
2150
+ }, _container10.rootContainerId),
2151
+ // position is inside #outside-overflow
2152
+ function (t) {
507
2153
  return t.id;
508
2154
  })).toBe('overflow-within');
509
2155
  }));
@@ -514,14 +2160,72 @@ describe('target', function () {
514
2160
  (0, _container10.configureContainer)('inside', {
515
2161
  enterTo: null
516
2162
  });
2163
+ var overflowContainer = root.querySelector('[data-spotlight-id="overflow-container"]');
2164
+ var insideContainer = root.querySelector('[data-spotlight-id="inside"]');
517
2165
  var element = root.querySelector('#outside-overflow');
2166
+ var inLargeContainer = root.querySelector('#in-large-container');
2167
+ var belowLargeContainer = root.querySelector('#below-large-container');
2168
+
2169
+ // Mock all bounding rects
2170
+ overflowContainer.getBoundingClientRect = function () {
2171
+ return {
2172
+ top: 50,
2173
+ left: 10,
2174
+ width: 40,
2175
+ height: 40,
2176
+ right: 50,
2177
+ bottom: 90
2178
+ };
2179
+ };
2180
+ insideContainer.getBoundingClientRect = function () {
2181
+ return {
2182
+ top: 40,
2183
+ left: 15,
2184
+ width: 30,
2185
+ height: 60,
2186
+ right: 45,
2187
+ bottom: 100
2188
+ };
2189
+ };
2190
+ element.getBoundingClientRect = function () {
2191
+ return {
2192
+ top: 10,
2193
+ left: 10,
2194
+ width: 10,
2195
+ height: 10,
2196
+ right: 20,
2197
+ bottom: 20
2198
+ };
2199
+ };
2200
+ inLargeContainer.getBoundingClientRect = function () {
2201
+ return {
2202
+ top: 60,
2203
+ left: 20,
2204
+ width: 10,
2205
+ height: 10,
2206
+ right: 30,
2207
+ bottom: 70
2208
+ };
2209
+ };
2210
+ belowLargeContainer.getBoundingClientRect = function () {
2211
+ return {
2212
+ top: 110,
2213
+ left: 10,
2214
+ width: 10,
2215
+ height: 10,
2216
+ right: 20,
2217
+ bottom: 120
2218
+ };
2219
+ };
518
2220
  var _element$getBoundingC2 = element.getBoundingClientRect(),
519
2221
  x = _element$getBoundingC2.left,
520
2222
  y = _element$getBoundingC2.top;
521
2223
  expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', {
522
- x: x,
523
- y: y
524
- }, _container10.rootContainerId), function (t) {
2224
+ x: x + 5,
2225
+ y: y + 5
2226
+ }, _container10.rootContainerId),
2227
+ // position is inside #outside-overflow
2228
+ function (t) {
525
2229
  return t.id;
526
2230
  })).toBe('in-large-container');
527
2231
  }));
@@ -529,12 +2233,57 @@ describe('target', function () {
529
2233
  (0, _container10.configureContainer)('overflow-container', {
530
2234
  overflow: true
531
2235
  });
532
- var element = root.querySelector('#overflow-within');
533
- var _element$getBoundingC3 = element.getBoundingClientRect(),
534
- left = _element$getBoundingC3.left,
535
- width = _element$getBoundingC3.width,
536
- top = _element$getBoundingC3.top,
537
- height = _element$getBoundingC3.height;
2236
+ var overflowContainer = root.querySelector('[data-spotlight-id="overflow-container"]');
2237
+ var overflowAbove = root.querySelector('#overflow-above');
2238
+ var overflowBelow = root.querySelector('#overflow-below');
2239
+ var overflowWithin = root.querySelector('#overflow-within');
2240
+
2241
+ // Mock all bounding rects
2242
+ overflowContainer.getBoundingClientRect = function () {
2243
+ return {
2244
+ top: 110,
2245
+ left: 10,
2246
+ width: 30,
2247
+ height: 30,
2248
+ right: 40,
2249
+ bottom: 140
2250
+ };
2251
+ };
2252
+ overflowAbove.getBoundingClientRect = function () {
2253
+ return {
2254
+ top: 100,
2255
+ left: 10,
2256
+ width: 10,
2257
+ height: 10,
2258
+ right: 20,
2259
+ bottom: 110
2260
+ };
2261
+ };
2262
+ overflowWithin.getBoundingClientRect = function () {
2263
+ return {
2264
+ top: 110,
2265
+ left: 10,
2266
+ width: 10,
2267
+ height: 10,
2268
+ right: 20,
2269
+ bottom: 120
2270
+ };
2271
+ };
2272
+ overflowBelow.getBoundingClientRect = function () {
2273
+ return {
2274
+ top: 140,
2275
+ left: 10,
2276
+ width: 10,
2277
+ height: 10,
2278
+ right: 20,
2279
+ bottom: 150
2280
+ };
2281
+ };
2282
+ var _overflowWithin$getBo = overflowWithin.getBoundingClientRect(),
2283
+ left = _overflowWithin$getBo.left,
2284
+ width = _overflowWithin$getBo.width,
2285
+ top = _overflowWithin$getBo.top,
2286
+ height = _overflowWithin$getBo.height;
538
2287
  var x = left + width / 2;
539
2288
  var y = top + height / 2;
540
2289
  expect(safeTarget((0, _target.getTargetByDirectionFromPosition)('down', {
@@ -552,12 +2301,46 @@ describe('target', function () {
552
2301
  }));
553
2302
  test('should ignore empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
554
2303
  (0, _container10.configureContainer)('empty-container');
555
- var element = root.querySelector('#above');
556
- var _element$getBoundingC4 = element.getBoundingClientRect(),
557
- left = _element$getBoundingC4.left,
558
- width = _element$getBoundingC4.width,
559
- top = _element$getBoundingC4.top,
560
- height = _element$getBoundingC4.height;
2304
+ var emptyContainer = root.querySelector('[data-spotlight-id="empty-container"]');
2305
+ var above = root.querySelector('#above');
2306
+ var below = root.querySelector('#below');
2307
+
2308
+ // Mock all bounding rects
2309
+ above.getBoundingClientRect = function () {
2310
+ return {
2311
+ top: 0,
2312
+ left: 10,
2313
+ width: 10,
2314
+ height: 10,
2315
+ right: 20,
2316
+ bottom: 10
2317
+ };
2318
+ };
2319
+ emptyContainer.getBoundingClientRect = function () {
2320
+ return {
2321
+ top: 10,
2322
+ left: 10,
2323
+ width: 10,
2324
+ height: 10,
2325
+ right: 20,
2326
+ bottom: 20
2327
+ };
2328
+ };
2329
+ below.getBoundingClientRect = function () {
2330
+ return {
2331
+ top: 30,
2332
+ left: 0,
2333
+ width: 10,
2334
+ height: 10,
2335
+ right: 10,
2336
+ bottom: 40
2337
+ };
2338
+ };
2339
+ var _above$getBoundingCli = above.getBoundingClientRect(),
2340
+ left = _above$getBoundingCli.left,
2341
+ width = _above$getBoundingCli.width,
2342
+ top = _above$getBoundingCli.top,
2343
+ height = _above$getBoundingCli.height;
561
2344
  var x = left + width / 2;
562
2345
  var y = top + height - 1; // just inside the bottom of 'above'
563
2346
 
@@ -570,12 +2353,46 @@ describe('target', function () {
570
2353
  }));
571
2354
  test('should ignore overlapping empty containers', (0, _utils.testScenario)(scenarios.emptyContainer, function (root) {
572
2355
  (0, _container10.configureContainer)('empty-container');
573
- var element = root.querySelector('#above');
574
- var _element$getBoundingC5 = element.getBoundingClientRect(),
575
- left = _element$getBoundingC5.left,
576
- width = _element$getBoundingC5.width,
577
- top = _element$getBoundingC5.top,
578
- height = _element$getBoundingC5.height;
2356
+ var emptyContainer = root.querySelector('[data-spotlight-id="empty-container"]');
2357
+ var above = root.querySelector('#above');
2358
+ var below = root.querySelector('#below');
2359
+
2360
+ // Mock all bounding rects
2361
+ above.getBoundingClientRect = function () {
2362
+ return {
2363
+ top: 0,
2364
+ left: 10,
2365
+ width: 10,
2366
+ height: 10,
2367
+ right: 20,
2368
+ bottom: 10
2369
+ };
2370
+ };
2371
+ emptyContainer.getBoundingClientRect = function () {
2372
+ return {
2373
+ top: 10,
2374
+ left: 10,
2375
+ width: 10,
2376
+ height: 10,
2377
+ right: 20,
2378
+ bottom: 20
2379
+ };
2380
+ };
2381
+ below.getBoundingClientRect = function () {
2382
+ return {
2383
+ top: 30,
2384
+ left: 0,
2385
+ width: 10,
2386
+ height: 10,
2387
+ right: 10,
2388
+ bottom: 40
2389
+ };
2390
+ };
2391
+ var _above$getBoundingCli2 = above.getBoundingClientRect(),
2392
+ left = _above$getBoundingCli2.left,
2393
+ width = _above$getBoundingCli2.width,
2394
+ top = _above$getBoundingCli2.top,
2395
+ height = _above$getBoundingCli2.height;
579
2396
  var x = left + width / 2;
580
2397
  var y = top + height + 1; // just inside the empty container
581
2398