@enact/spotlight 4.7.9 → 4.7.10
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/Accelerator/Accelerator.js +2 -2
- package/CHANGELOG.md +18 -0
- package/Pause/Pause.js +2 -2
- package/Pause/tests/Pause-specs.js +2 -2
- package/README.md +1 -1
- package/SpotlightContainerDecorator/SpotlightContainer.js +2 -2
- package/SpotlightContainerDecorator/SpotlightContainerDecorator.js +4 -4
- package/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +2 -2
- package/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +2 -2
- package/SpotlightContainerDecorator/useSpotlightContainer.js +1 -0
- package/SpotlightRootDecorator/SpotlightRootDecorator.js +13 -13
- package/SpotlightRootDecorator/tests/SpotlightRootDecorator-specs.js +2 -2
- package/Spottable/Spottable.js +4 -4
- package/Spottable/SpottableCore.js +2 -2
- package/Spottable/tests/Spottable-specs.js +2 -2
- package/Spottable/tests/useSpot-specs.js +4 -4
- package/Spottable/useSpottable.js +2 -2
- package/package.json +2 -2
- package/src/container.js +28 -7
- package/src/target.js +21 -5
- package/src/tests/container-specs.js +197 -178
- package/src/tests/spotlight-specs.js +5 -6
- package/src/tests/target-specs.js +14 -16
- package/src/tests/utils-specs.js +76 -0
- package/src/tests/utils.js +3 -4
- package/src/utils.js +29 -1
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _container19 = require("../container");
|
|
4
4
|
var _utils = require("./utils");
|
|
5
|
-
var _node, _container, _container2, _container3, _container4, _container5, _container6, _container7, _container8, _container9, _container10, _container11, _container12, _container13, _container15, _container16;
|
|
6
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
-
function _toPropertyKey(
|
|
8
|
-
function _toPrimitive(
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
8
|
var nonSpottable = function nonSpottable() {
|
|
10
9
|
return (0, _utils.node)({
|
|
11
10
|
className: 'other'
|
|
@@ -17,61 +16,66 @@ var scenarios = {
|
|
|
17
16
|
spottableAndContainers: (0, _utils.someSpottablesAndContainers)(5),
|
|
18
17
|
nonSpottableSiblings: (0, _utils.join)((0, _utils.someSpottables)(5), (0, _utils.someNodes)(nonSpottable, 5)),
|
|
19
18
|
nestedContainers: (0, _utils.container)((0, _utils.container)((0, _utils.container)())),
|
|
20
|
-
disabledContainers: (0, _utils.join)((0, _utils.someSpottables)(5), (0, _utils.someContainers)(5), (0, _utils.node)((
|
|
19
|
+
disabledContainers: (0, _utils.join)((0, _utils.someSpottables)(5), (0, _utils.someContainers)(5), (0, _utils.node)(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'disabled-container'), 'data-spotlight-container-disabled', true))),
|
|
21
20
|
nestedContainersWithSpottables: (0, _utils.join)((0, _utils.someSpottables)(5), (0, _utils.container)({
|
|
22
21
|
children: (0, _utils.someSpottables)(5)
|
|
23
22
|
})),
|
|
24
|
-
siblingContainers: (0, _utils.join)((0, _utils.container)((
|
|
25
|
-
mixedOrder: (0, _utils.join)((0, _utils.container)((
|
|
23
|
+
siblingContainers: (0, _utils.join)((0, _utils.container)(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'first'), "children", (0, _utils.someSpottables)(5))), (0, _utils.container)(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'second'), "children", (0, _utils.someSpottables)(5)))),
|
|
24
|
+
mixedOrder: (0, _utils.join)((0, _utils.container)(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'first'), "name", 'c1')), (0, _utils.spottable)({
|
|
26
25
|
name: 's1'
|
|
27
|
-
}), (0, _utils.container)((
|
|
26
|
+
}), (0, _utils.container)(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'second'), "name", 'c2')), (0, _utils.spottable)({
|
|
28
27
|
name: 's2'
|
|
29
28
|
})),
|
|
30
|
-
complexTree: (0, _utils.join)((0, _utils.spottable)(nonSpottable()), (0, _utils.container)((
|
|
29
|
+
complexTree: (0, _utils.join)((0, _utils.spottable)(nonSpottable()), (0, _utils.container)(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'first-container'), "children", (0, _utils.join)((0, _utils.someSpottables)(2), (0, _utils.container)(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'second-container'), "children", (0, _utils.join)((0, _utils.spottable)({
|
|
31
30
|
id: 'secondContainerFirstSpottable'
|
|
32
|
-
}), (0, _utils.someSpottables)(2), (0, _utils.container)((
|
|
31
|
+
}), (0, _utils.someSpottables)(2), (0, _utils.container)(_defineProperty(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'third-container'), 'data-spotlight-container-disabled', true), "children", (0, _utils.join)((0, _utils.someSpottables)(4), (0, _utils.node)({
|
|
33
32
|
id: 'child-of-third'
|
|
34
|
-
})))
|
|
35
|
-
spottablesInDisabledContainer: (0, _utils.container)((
|
|
36
|
-
spottablesInNestedDisabledContainer: (0, _utils.container)((
|
|
37
|
-
containerWithDefaultAndLastFocused: (0, _utils.container)((
|
|
33
|
+
}))))))))))),
|
|
34
|
+
spottablesInDisabledContainer: (0, _utils.container)(_defineProperty(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'container'), 'data-spotlight-container-disabled', true), "children", (0, _utils.someSpottables)(5))),
|
|
35
|
+
spottablesInNestedDisabledContainer: (0, _utils.container)(_defineProperty(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'container'), 'data-spotlight-container-disabled', true), "children", (0, _utils.container)(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'child'), "children", (0, _utils.someSpottables)(5))))),
|
|
36
|
+
containerWithDefaultAndLastFocused: (0, _utils.container)(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'container'), "children", (0, _utils.join)((0, _utils.spottable)({
|
|
38
37
|
id: 'firstSpottable'
|
|
39
38
|
}), (0, _utils.someSpottables)(5), (0, _utils.node)({
|
|
40
39
|
id: 'spottableDefault',
|
|
41
40
|
className: 'spottable spottable-default'
|
|
42
41
|
}), (0, _utils.spottable)({
|
|
43
42
|
id: 'lastFocused'
|
|
44
|
-
})))
|
|
45
|
-
nestedContainersWithDefaultAndLastFocused: (0, _utils.container)((
|
|
43
|
+
})))),
|
|
44
|
+
nestedContainersWithDefaultAndLastFocused: (0, _utils.container)(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'container'), "children", (0, _utils.join)((0, _utils.spottable)({
|
|
46
45
|
id: 'firstSpottable'
|
|
47
|
-
}), (0, _utils.someSpottables)(5), (0, _utils.container)((
|
|
46
|
+
}), (0, _utils.someSpottables)(5), (0, _utils.container)(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'child'), "id", 'spottableDefault'), "className", 'spottable-default'), "children", (0, _utils.join)((0, _utils.spottable)({
|
|
48
47
|
id: 'firstChildSpottable'
|
|
49
48
|
}), (0, _utils.someSpottables)(5), (0, _utils.spottable)({
|
|
50
49
|
id: 'lastChildFocused'
|
|
51
|
-
})))
|
|
50
|
+
})))), (0, _utils.spottable)({
|
|
52
51
|
id: 'lastFocused'
|
|
53
|
-
})))
|
|
54
|
-
emptySubcontainer: (0, _utils.container)((
|
|
52
|
+
})))),
|
|
53
|
+
emptySubcontainer: (0, _utils.container)(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'container'), "children", (0, _utils.join)((0, _utils.container)(_defineProperty({}, _container19.containerAttribute, 'subcontainer')), (0, _utils.spottable)({
|
|
55
54
|
id: 'afterSubcontainer'
|
|
56
|
-
})))
|
|
55
|
+
})))),
|
|
57
56
|
owned: (0, _utils.join)((0, _utils.spottable)({
|
|
58
57
|
id: 's1'
|
|
59
58
|
}), (0, _utils.node)({
|
|
60
59
|
id: 'n1'
|
|
61
|
-
}), (0, _utils.container)((
|
|
60
|
+
}), (0, _utils.container)(_defineProperty(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'container'), 'aria-owns', 's1 n1'), "children", (0, _utils.spottable)({
|
|
62
61
|
id: 's2'
|
|
63
|
-
}))
|
|
62
|
+
})))),
|
|
63
|
+
positionTargetOnFocusContainer: (0, _utils.container)(_defineProperty(_defineProperty({
|
|
64
|
+
id: 'positionTargetContainer'
|
|
65
|
+
}, _container19.containerAttribute, 'positionTargetContainer'), "children", (0, _utils.join)((0, _utils.container)(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, _container19.containerAttribute, 'child'), "id", 'spottableDefault'), "className", 'spottable-default'), "children", (0, _utils.join)((0, _utils.spottable)({
|
|
66
|
+
id: 'firstChildSpottable'
|
|
67
|
+
})))))))
|
|
64
68
|
};
|
|
65
69
|
var setupContainers = function setupContainers() {
|
|
66
|
-
(0,
|
|
70
|
+
(0, _container19.configureDefaults)({
|
|
67
71
|
selector: '.spottable'
|
|
68
72
|
});
|
|
69
|
-
(0,
|
|
70
|
-
(0,
|
|
73
|
+
(0, _container19.configureContainer)(_container19.rootContainerId);
|
|
74
|
+
(0, _container19.setLastContainer)(_container19.rootContainerId);
|
|
71
75
|
};
|
|
72
76
|
var teardownContainers = function teardownContainers() {
|
|
73
77
|
// clean up any containers we create for safe tests
|
|
74
|
-
(0,
|
|
78
|
+
(0, _container19.removeAllContainers)();
|
|
75
79
|
};
|
|
76
80
|
describe('container', function () {
|
|
77
81
|
describe('#getSpottableDescendants', function () {
|
|
@@ -79,79 +83,79 @@ describe('container', function () {
|
|
|
79
83
|
afterEach(teardownContainers);
|
|
80
84
|
test('should find spottables', (0, _utils.testScenario)(scenarios.onlySpottables, function () {
|
|
81
85
|
var expected = 5;
|
|
82
|
-
var actual = (0,
|
|
86
|
+
var actual = (0, _container19.getSpottableDescendants)(_container19.rootContainerId).length;
|
|
83
87
|
expect(actual).toBe(expected);
|
|
84
88
|
}));
|
|
85
89
|
test('should find containers', (0, _utils.testScenario)(scenarios.onlyContainers, function () {
|
|
86
90
|
var expected = 5;
|
|
87
|
-
var actual = (0,
|
|
91
|
+
var actual = (0, _container19.getSpottableDescendants)(_container19.rootContainerId).length;
|
|
88
92
|
expect(actual).toBe(expected);
|
|
89
93
|
}));
|
|
90
94
|
test('should find spottables and containers', (0, _utils.testScenario)(scenarios.spottableAndContainers, function () {
|
|
91
95
|
var expected = 10;
|
|
92
|
-
var actual = (0,
|
|
96
|
+
var actual = (0, _container19.getSpottableDescendants)(_container19.rootContainerId).length;
|
|
93
97
|
expect(actual).toBe(expected);
|
|
94
98
|
}));
|
|
95
99
|
test('should only find spottables with non-spottable siblings', (0, _utils.testScenario)(scenarios.nonSpottableSiblings, function () {
|
|
96
100
|
var expected = 5;
|
|
97
|
-
var actual = (0,
|
|
101
|
+
var actual = (0, _container19.getSpottableDescendants)(_container19.rootContainerId).length;
|
|
98
102
|
expect(actual).toBe(expected);
|
|
99
103
|
}));
|
|
100
104
|
test('should only find top-level containers', (0, _utils.testScenario)(scenarios.nestedContainers, function () {
|
|
101
105
|
var expected = 1;
|
|
102
|
-
var actual = (0,
|
|
106
|
+
var actual = (0, _container19.getSpottableDescendants)(_container19.rootContainerId).length;
|
|
103
107
|
expect(actual).toBe(expected);
|
|
104
108
|
}));
|
|
105
109
|
test('should only find top-level containers and spottables', (0, _utils.testScenario)(scenarios.nestedContainersWithSpottables, function () {
|
|
106
110
|
var expected = 6;
|
|
107
|
-
var actual = (0,
|
|
111
|
+
var actual = (0, _container19.getSpottableDescendants)(_container19.rootContainerId).length;
|
|
108
112
|
expect(actual).toBe(expected);
|
|
109
113
|
}));
|
|
110
114
|
test('should not find spottables in sibling containers', (0, _utils.testScenario)(scenarios.siblingContainers, function () {
|
|
111
|
-
(0,
|
|
115
|
+
(0, _container19.configureContainer)('first');
|
|
112
116
|
var expected = 5;
|
|
113
|
-
var actual = (0,
|
|
117
|
+
var actual = (0, _container19.getSpottableDescendants)('first').length;
|
|
114
118
|
expect(actual).toBe(expected);
|
|
115
119
|
}));
|
|
116
120
|
test('should not find spottables in descendant containers', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
117
|
-
(0,
|
|
121
|
+
(0, _container19.configureContainer)('first-container');
|
|
118
122
|
var expected = 3;
|
|
119
|
-
var actual = (0,
|
|
123
|
+
var actual = (0, _container19.getSpottableDescendants)('first-container').length;
|
|
120
124
|
expect(actual).toBe(expected);
|
|
121
125
|
}));
|
|
122
126
|
test('should not find containers that are disabled', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
123
|
-
(0,
|
|
124
|
-
(0,
|
|
127
|
+
(0, _container19.configureContainer)('first-container');
|
|
128
|
+
(0, _container19.configureContainer)('second-container');
|
|
125
129
|
var expected = 3;
|
|
126
|
-
var actual = (0,
|
|
130
|
+
var actual = (0, _container19.getSpottableDescendants)('second-container').length;
|
|
127
131
|
expect(actual).toBe(expected);
|
|
128
132
|
}));
|
|
129
133
|
test('should not any spottables within a disabled container', (0, _utils.testScenario)(scenarios.spottablesInDisabledContainer, function () {
|
|
130
|
-
(0,
|
|
134
|
+
(0, _container19.configureContainer)('container');
|
|
131
135
|
var expected = 0;
|
|
132
|
-
var actual = (0,
|
|
136
|
+
var actual = (0, _container19.getSpottableDescendants)('container').length;
|
|
133
137
|
expect(actual).toBe(expected);
|
|
134
138
|
}));
|
|
135
139
|
test('should not any spottables within a disabled ancestor container', (0, _utils.testScenario)(scenarios.spottablesInNestedDisabledContainer, function () {
|
|
136
|
-
(0,
|
|
137
|
-
(0,
|
|
140
|
+
(0, _container19.configureContainer)('container');
|
|
141
|
+
(0, _container19.configureContainer)('child');
|
|
138
142
|
var expected = 0;
|
|
139
|
-
var actual = (0,
|
|
143
|
+
var actual = (0, _container19.getSpottableDescendants)('child').length;
|
|
140
144
|
expect(actual).toBe(expected);
|
|
141
145
|
}));
|
|
142
146
|
test('should return spottables and containers in source order', (0, _utils.testScenario)(scenarios.mixedOrder, function () {
|
|
143
147
|
var expected = ['c1', 's1', 'c2', 's2'];
|
|
144
|
-
var actual = (0,
|
|
148
|
+
var actual = (0, _container19.getSpottableDescendants)(_container19.rootContainerId).map(function (n) {
|
|
145
149
|
return n.getAttribute('name');
|
|
146
150
|
});
|
|
147
151
|
expect(actual).toEqual(expected);
|
|
148
152
|
}));
|
|
149
153
|
test('should include owned nodes', (0, _utils.testScenario)(scenarios.owned, function () {
|
|
150
|
-
(0,
|
|
154
|
+
(0, _container19.configureContainer)('container');
|
|
151
155
|
|
|
152
156
|
// owned nodes follow internal nodes
|
|
153
157
|
var expected = ['s2', 's1'];
|
|
154
|
-
var actual = (0,
|
|
158
|
+
var actual = (0, _container19.getSpottableDescendants)('container').map(function (n) {
|
|
155
159
|
return n.getAttribute('id');
|
|
156
160
|
});
|
|
157
161
|
expect(actual).toEqual(expected);
|
|
@@ -159,51 +163,51 @@ describe('container', function () {
|
|
|
159
163
|
});
|
|
160
164
|
describe('#getContainersForNode', function () {
|
|
161
165
|
test('should return the rootContainerId when no other containers exist', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
|
|
162
|
-
var expected = [
|
|
163
|
-
var actual = (0,
|
|
166
|
+
var expected = [_container19.rootContainerId];
|
|
167
|
+
var actual = (0, _container19.getContainersForNode)(root.lastChild);
|
|
164
168
|
expect(actual).toEqual(expected);
|
|
165
169
|
}));
|
|
166
170
|
test('should return all ancestor container ids', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
167
171
|
var childOfThird = root.querySelector('#child-of-third');
|
|
168
|
-
var expected = [
|
|
169
|
-
var actual = (0,
|
|
172
|
+
var expected = [_container19.rootContainerId, 'first-container', 'second-container', 'third-container'];
|
|
173
|
+
var actual = (0, _container19.getContainersForNode)(childOfThird);
|
|
170
174
|
expect(actual).toEqual(expected);
|
|
171
175
|
}));
|
|
172
176
|
test('should return immediate container id as last in list', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
173
177
|
var childOfThird = root.querySelector('#child-of-third');
|
|
174
178
|
var expected = 'third-container';
|
|
175
|
-
var actual = (0,
|
|
179
|
+
var actual = (0, _container19.getContainersForNode)(childOfThird).pop();
|
|
176
180
|
expect(actual).toEqual(expected);
|
|
177
181
|
}));
|
|
178
182
|
});
|
|
179
183
|
describe('#isContainer', function () {
|
|
180
184
|
beforeEach(function () {
|
|
181
|
-
(0,
|
|
185
|
+
(0, _container19.configureContainer)('test-container');
|
|
182
186
|
});
|
|
183
187
|
afterEach(function () {
|
|
184
|
-
(0,
|
|
188
|
+
(0, _container19.removeContainer)('test-container');
|
|
185
189
|
});
|
|
186
190
|
test('should return true for nodes that have the container attribute', function () {
|
|
187
191
|
var div = document.createElement('div');
|
|
188
192
|
div.setAttribute('data-spotlight-container', 'my-container');
|
|
189
193
|
var expected = true;
|
|
190
|
-
var actual = (0,
|
|
194
|
+
var actual = (0, _container19.isContainer)(div);
|
|
191
195
|
expect(actual).toBe(expected);
|
|
192
196
|
});
|
|
193
197
|
test('should return false for nodes that do not have the container attribute', function () {
|
|
194
198
|
var div = document.createElement('div');
|
|
195
199
|
var expected = false;
|
|
196
|
-
var actual = (0,
|
|
200
|
+
var actual = (0, _container19.isContainer)(div);
|
|
197
201
|
expect(actual).toBe(expected);
|
|
198
202
|
});
|
|
199
203
|
test('should return true for a configured container id', function () {
|
|
200
204
|
var expected = true;
|
|
201
|
-
var actual = (0,
|
|
205
|
+
var actual = (0, _container19.isContainer)('test-container');
|
|
202
206
|
expect(actual).toBe(expected);
|
|
203
207
|
});
|
|
204
208
|
test('should return false for a unconfigured container id', function () {
|
|
205
209
|
var expected = false;
|
|
206
|
-
var actual = (0,
|
|
210
|
+
var actual = (0, _container19.isContainer)('unconfigured-container');
|
|
207
211
|
expect(actual).toBe(expected);
|
|
208
212
|
});
|
|
209
213
|
});
|
|
@@ -211,160 +215,160 @@ describe('container', function () {
|
|
|
211
215
|
beforeEach(setupContainers);
|
|
212
216
|
afterEach(teardownContainers);
|
|
213
217
|
test('should return the last focused element when enterTo is "last-focused"', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function (root) {
|
|
214
|
-
(0,
|
|
218
|
+
(0, _container19.configureContainer)('container', {
|
|
215
219
|
enterTo: 'last-focused',
|
|
216
220
|
defaultElement: '.spottable-default'
|
|
217
221
|
});
|
|
218
|
-
(0,
|
|
222
|
+
(0, _container19.setContainerLastFocusedElement)(root.querySelector('#lastFocused'), ['container']);
|
|
219
223
|
var expected = 'lastFocused';
|
|
220
|
-
var actual = (0,
|
|
224
|
+
var actual = (0, _container19.getContainerFocusTarget)('container').id;
|
|
221
225
|
expect(actual).toBe(expected);
|
|
222
226
|
}));
|
|
223
227
|
test('should return the default spottable element when enterTo is "last-focused" but no element has been focused', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
224
|
-
(0,
|
|
228
|
+
(0, _container19.configureContainer)('container', {
|
|
225
229
|
enterTo: 'last-focused',
|
|
226
230
|
defaultElement: '.spottable-default'
|
|
227
231
|
});
|
|
228
232
|
var expected = 'spottableDefault';
|
|
229
|
-
var actual = (0,
|
|
233
|
+
var actual = (0, _container19.getContainerFocusTarget)('container').id;
|
|
230
234
|
expect(actual).toBe(expected);
|
|
231
235
|
}));
|
|
232
236
|
test('should return the first spottable element when enterTo is "last-focused" and defaultElement is not configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
233
|
-
(0,
|
|
237
|
+
(0, _container19.configureContainer)('container', {
|
|
234
238
|
enterTo: 'last-focused'
|
|
235
239
|
});
|
|
236
240
|
var expected = 'firstSpottable';
|
|
237
|
-
var actual = (0,
|
|
241
|
+
var actual = (0, _container19.getContainerFocusTarget)('container').id;
|
|
238
242
|
expect(actual).toBe(expected);
|
|
239
243
|
}));
|
|
240
244
|
test('should return the first spottable element when enterTo is "last-focused" and defaultElement is not found', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
241
|
-
(0,
|
|
245
|
+
(0, _container19.configureContainer)('container', {
|
|
242
246
|
enterTo: 'last-focused',
|
|
243
247
|
// configured, but not found
|
|
244
248
|
defaultElement: '[data-default-spottable]'
|
|
245
249
|
});
|
|
246
250
|
var expected = 'firstSpottable';
|
|
247
|
-
var actual = (0,
|
|
251
|
+
var actual = (0, _container19.getContainerFocusTarget)('container').id;
|
|
248
252
|
expect(actual).toBe(expected);
|
|
249
253
|
}));
|
|
250
254
|
test('should return the default spottable element when enterTo is "default-element"', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
251
|
-
(0,
|
|
255
|
+
(0, _container19.configureContainer)('container', {
|
|
252
256
|
enterTo: 'default-element',
|
|
253
257
|
defaultElement: '.spottable-default'
|
|
254
258
|
});
|
|
255
259
|
var expected = 'spottableDefault';
|
|
256
|
-
var actual = (0,
|
|
260
|
+
var actual = (0, _container19.getContainerFocusTarget)('container').id;
|
|
257
261
|
expect(actual).toBe(expected);
|
|
258
262
|
}));
|
|
259
263
|
test('should return the default spottable element when enterTo is "default-element" and defaultElement contains an array of selectors', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
260
|
-
(0,
|
|
264
|
+
(0, _container19.configureContainer)('container', {
|
|
261
265
|
enterTo: 'default-element',
|
|
262
266
|
defaultElement: ['.does-not-exist', '.spottable-default']
|
|
263
267
|
});
|
|
264
268
|
var expected = 'spottableDefault';
|
|
265
|
-
var actual = (0,
|
|
269
|
+
var actual = (0, _container19.getContainerFocusTarget)('container').id;
|
|
266
270
|
expect(actual).toBe(expected);
|
|
267
271
|
}));
|
|
268
272
|
|
|
269
273
|
// FIXME: This is testing a previously supported feature (setting a node as defaultElement)
|
|
270
274
|
// which was never documented and should be removed in a future release.
|
|
271
275
|
test('should return the default spottable element when enterTo is "default-element" and defaultElement contains an array of selectors wiht a node reference', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function (root) {
|
|
272
|
-
(0,
|
|
276
|
+
(0, _container19.configureContainer)('container', {
|
|
273
277
|
enterTo: 'default-element',
|
|
274
278
|
defaultElement: [root.querySelector('#lastFocused'), '.spottable-default']
|
|
275
279
|
});
|
|
276
280
|
var expected = 'lastFocused';
|
|
277
|
-
var actual = (0,
|
|
281
|
+
var actual = (0, _container19.getContainerFocusTarget)('container').id;
|
|
278
282
|
expect(actual).toBe(expected);
|
|
279
283
|
}));
|
|
280
284
|
test('should return the first spottable element when enterTo is "default-element" but defaultElement is not configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
281
|
-
(0,
|
|
285
|
+
(0, _container19.configureContainer)('container', {
|
|
282
286
|
enterTo: 'default-element'
|
|
283
287
|
});
|
|
284
288
|
var expected = 'firstSpottable';
|
|
285
|
-
var actual = (0,
|
|
289
|
+
var actual = (0, _container19.getContainerFocusTarget)('container').id;
|
|
286
290
|
expect(actual).toBe(expected);
|
|
287
291
|
}));
|
|
288
292
|
test('should return the first spottable element when enterTo is "default-element" but defaultElement is not found', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
289
|
-
(0,
|
|
293
|
+
(0, _container19.configureContainer)('container', {
|
|
290
294
|
enterTo: 'default-element',
|
|
291
295
|
defaultElement: '[data-default-spottable]'
|
|
292
296
|
});
|
|
293
297
|
var expected = 'firstSpottable';
|
|
294
|
-
var actual = (0,
|
|
298
|
+
var actual = (0, _container19.getContainerFocusTarget)('container').id;
|
|
295
299
|
expect(actual).toBe(expected);
|
|
296
300
|
}));
|
|
297
301
|
test('should return the default element when enterTo is "default-element" and defaultElement is within a subcontainer', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
298
|
-
(0,
|
|
302
|
+
(0, _container19.configureContainer)('first-container', {
|
|
299
303
|
enterTo: 'default-element',
|
|
300
|
-
defaultElement: "[".concat(
|
|
304
|
+
defaultElement: "[".concat(_container19.containerAttribute, "='second-container'] > .spottable")
|
|
301
305
|
});
|
|
302
|
-
(0,
|
|
306
|
+
(0, _container19.configureContainer)('second-container');
|
|
303
307
|
var expected = 'second-container';
|
|
304
|
-
var actual = (0,
|
|
308
|
+
var actual = (0, _container19.getContainerFocusTarget)('first-container').parentNode.dataset.spotlightId;
|
|
305
309
|
expect(actual).toBe(expected);
|
|
306
310
|
}));
|
|
307
311
|
test('should return the first spottable element when enterTo is "default-element" and defaultElement is within a disabled subcontainer', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
308
|
-
(0,
|
|
312
|
+
(0, _container19.configureContainer)('second-container', {
|
|
309
313
|
enterTo: 'default-element',
|
|
310
|
-
defaultElement: "[".concat(
|
|
314
|
+
defaultElement: "[".concat(_container19.containerAttribute, "='third-container'] > .spottable")
|
|
311
315
|
});
|
|
312
|
-
(0,
|
|
316
|
+
(0, _container19.configureContainer)('third-container');
|
|
313
317
|
var expected = 'secondContainerFirstSpottable';
|
|
314
|
-
var actual = (0,
|
|
318
|
+
var actual = (0, _container19.getContainerFocusTarget)('second-container').id;
|
|
315
319
|
expect(actual).toBe(expected);
|
|
316
320
|
}));
|
|
317
321
|
test('should return the first spottable element when enterTo is not configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
318
|
-
(0,
|
|
322
|
+
(0, _container19.configureContainer)('container');
|
|
319
323
|
var expected = 'firstSpottable';
|
|
320
|
-
var actual = (0,
|
|
324
|
+
var actual = (0, _container19.getContainerFocusTarget)('container').id;
|
|
321
325
|
expect(actual).toBe(expected);
|
|
322
326
|
}));
|
|
323
327
|
test('should return the default element when enterTo is not configured and defaultElement is configured', (0, _utils.testScenario)(scenarios.containerWithDefaultAndLastFocused, function () {
|
|
324
|
-
(0,
|
|
328
|
+
(0, _container19.configureContainer)('container', {
|
|
325
329
|
defaultElement: '.spottable-default'
|
|
326
330
|
});
|
|
327
331
|
var expected = 'spottableDefault';
|
|
328
|
-
var actual = (0,
|
|
332
|
+
var actual = (0, _container19.getContainerFocusTarget)('container').id;
|
|
329
333
|
expect(actual).toBe(expected);
|
|
330
334
|
}));
|
|
331
335
|
test('should cascade search into child containers with', (0, _utils.testScenario)(scenarios.nestedContainersWithDefaultAndLastFocused, function (root) {
|
|
332
|
-
(0,
|
|
336
|
+
(0, _container19.configureContainer)('container', {
|
|
333
337
|
defaultElement: '.spottable-default'
|
|
334
338
|
});
|
|
335
|
-
(0,
|
|
339
|
+
(0, _container19.configureContainer)('child', {
|
|
336
340
|
enterTo: 'last-focused',
|
|
337
341
|
defaultElement: '.spottable-default'
|
|
338
342
|
});
|
|
339
|
-
(0,
|
|
343
|
+
(0, _container19.setContainerLastFocusedElement)(root.querySelector('#lastChildFocused'), [_container19.rootContainerId, 'container', 'child']);
|
|
340
344
|
var expected = 'lastChildFocused';
|
|
341
|
-
var actual = (0,
|
|
345
|
+
var actual = (0, _container19.getContainerFocusTarget)('container').id;
|
|
342
346
|
expect(actual).toBe(expected);
|
|
343
347
|
}));
|
|
344
348
|
test('should cascade search into child containers when multiple containers have enterTo configured', (0, _utils.testScenario)(scenarios.nestedContainersWithDefaultAndLastFocused, function (root) {
|
|
345
|
-
(0,
|
|
349
|
+
(0, _container19.configureContainer)('container', {
|
|
346
350
|
enterTo: 'last-focused',
|
|
347
351
|
defaultElement: '.spottable-default'
|
|
348
352
|
});
|
|
349
|
-
(0,
|
|
353
|
+
(0, _container19.configureContainer)('child', {
|
|
350
354
|
enterTo: 'last-focused',
|
|
351
355
|
defaultElement: '.spottable-default'
|
|
352
356
|
});
|
|
353
|
-
(0,
|
|
357
|
+
(0, _container19.setContainerLastFocusedElement)(root.querySelector('#lastChildFocused'), [_container19.rootContainerId, 'container', 'child']);
|
|
354
358
|
var expected = 'lastChildFocused';
|
|
355
|
-
var actual = (0,
|
|
359
|
+
var actual = (0, _container19.getContainerFocusTarget)('container').id;
|
|
356
360
|
expect(actual).toBe(expected);
|
|
357
361
|
}));
|
|
358
362
|
test('should skip empty subcontainers', (0, _utils.testScenario)(scenarios.emptySubcontainer, function () {
|
|
359
|
-
(0,
|
|
360
|
-
(0,
|
|
363
|
+
(0, _container19.configureContainer)('container');
|
|
364
|
+
(0, _container19.configureContainer)('subcontainer');
|
|
361
365
|
var expected = 'afterSubcontainer';
|
|
362
|
-
var actual = (0,
|
|
366
|
+
var actual = (0, _container19.getContainerFocusTarget)('container').id;
|
|
363
367
|
expect(actual).toBe(expected);
|
|
364
368
|
}));
|
|
365
369
|
test('should return null for an unconfigured container', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
366
370
|
var expected = null;
|
|
367
|
-
var actual = (0,
|
|
371
|
+
var actual = (0, _container19.getContainerFocusTarget)('first-container');
|
|
368
372
|
expect(actual).toBe(expected);
|
|
369
373
|
}));
|
|
370
374
|
});
|
|
@@ -373,33 +377,33 @@ describe('container', function () {
|
|
|
373
377
|
afterEach(teardownContainers);
|
|
374
378
|
test('should return false a null node', function () {
|
|
375
379
|
var expected = false;
|
|
376
|
-
var actual = (0,
|
|
380
|
+
var actual = (0, _container19.isNavigable)(null, _container19.rootContainerId);
|
|
377
381
|
expect(actual).toBe(expected);
|
|
378
382
|
});
|
|
379
383
|
test('should return true for any node when not verifying selector and without a navigableFilter', (0, _utils.testScenario)(scenarios.nonSpottableSiblings, function (root) {
|
|
380
384
|
var expected = true;
|
|
381
|
-
var actual = (0,
|
|
385
|
+
var actual = (0, _container19.isNavigable)(root.querySelector('.other'), _container19.rootContainerId);
|
|
382
386
|
expect(actual).toBe(expected);
|
|
383
387
|
}));
|
|
384
388
|
test('should return true for spottable children when verifying selector', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
|
|
385
389
|
var expected = true;
|
|
386
|
-
var actual = (0,
|
|
390
|
+
var actual = (0, _container19.isNavigable)(root.querySelector('.spottable'), _container19.rootContainerId, true);
|
|
387
391
|
expect(actual).toBe(expected);
|
|
388
392
|
}));
|
|
389
393
|
test('should return true for containers', (0, _utils.testScenario)(scenarios.onlyContainers, function (root) {
|
|
390
394
|
var expected = true;
|
|
391
|
-
var actual = (0,
|
|
395
|
+
var actual = (0, _container19.isNavigable)(root.querySelector("[".concat(_container19.containerAttribute, "]")), _container19.rootContainerId, true);
|
|
392
396
|
expect(actual).toBe(expected);
|
|
393
397
|
}));
|
|
394
398
|
test('should filter the node with navigableFilter', (0, _utils.testScenario)(scenarios.spottableAndContainers, function (root) {
|
|
395
|
-
(0,
|
|
399
|
+
(0, _container19.configureContainer)(_container19.rootContainerId, {
|
|
396
400
|
// test filter which makes containers non-navigable
|
|
397
401
|
navigableFilter: function navigableFilter(n) {
|
|
398
|
-
return !(0,
|
|
402
|
+
return !(0, _container19.isContainer)(n);
|
|
399
403
|
}
|
|
400
404
|
});
|
|
401
405
|
var expected = false;
|
|
402
|
-
var actual = (0,
|
|
406
|
+
var actual = (0, _container19.isNavigable)(root.querySelector("[".concat(_container19.containerAttribute, "]")), _container19.rootContainerId, true);
|
|
403
407
|
expect(actual).toBe(expected);
|
|
404
408
|
}));
|
|
405
409
|
});
|
|
@@ -408,36 +412,36 @@ describe('container', function () {
|
|
|
408
412
|
afterEach(teardownContainers);
|
|
409
413
|
test('should update lastFocusedElement for a single container', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
|
|
410
414
|
var item = root.querySelectorAll('.spottable').item(3);
|
|
411
|
-
(0,
|
|
415
|
+
(0, _container19.setContainerLastFocusedElement)(item, (0, _container19.getContainersForNode)(item));
|
|
412
416
|
var expected = item;
|
|
413
|
-
var actual = (0,
|
|
417
|
+
var actual = (0, _container19.getContainerConfig)(_container19.rootContainerId).lastFocusedElement;
|
|
414
418
|
expect(actual).toBe(expected);
|
|
415
419
|
}));
|
|
416
420
|
test('should update lastFocusedElement to the node\'s container id when element is within a container with enterTo configured', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
417
|
-
var item = root.querySelectorAll("[".concat(
|
|
418
|
-
(0,
|
|
421
|
+
var item = root.querySelectorAll("[".concat(_container19.containerAttribute, "='first-container'] .spottable")).item(0);
|
|
422
|
+
(0, _container19.configureContainer)('first-container', {
|
|
419
423
|
enterTo: 'last-focused'
|
|
420
424
|
});
|
|
421
|
-
(0,
|
|
425
|
+
(0, _container19.setContainerLastFocusedElement)(item, (0, _container19.getContainersForNode)(item));
|
|
422
426
|
var expected = 'first-container';
|
|
423
|
-
var actual = (0,
|
|
427
|
+
var actual = (0, _container19.getContainerConfig)(_container19.rootContainerId).lastFocusedElement;
|
|
424
428
|
expect(actual).toBe(expected);
|
|
425
429
|
}));
|
|
426
430
|
test('should ignore sub-containers that does not have enterTo configured', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
427
|
-
var item = root.querySelectorAll("[".concat(
|
|
428
|
-
(0,
|
|
431
|
+
var item = root.querySelectorAll("[".concat(_container19.containerAttribute, "='second-container'] .spottable")).item(0);
|
|
432
|
+
(0, _container19.setContainerLastFocusedElement)(item, (0, _container19.getContainersForNode)(item));
|
|
429
433
|
var expected = item;
|
|
430
|
-
var actual = (0,
|
|
434
|
+
var actual = (0, _container19.getContainerConfig)(_container19.rootContainerId).lastFocusedElement;
|
|
431
435
|
expect(actual).toBe(expected);
|
|
432
436
|
}));
|
|
433
437
|
test('should update lastFocusedElement to the first sub-container that has enterTo configured', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
434
|
-
var item = root.querySelectorAll("[".concat(
|
|
435
|
-
(0,
|
|
438
|
+
var item = root.querySelectorAll("[".concat(_container19.containerAttribute, "='second-container'] .spottable")).item(0);
|
|
439
|
+
(0, _container19.configureContainer)('second-container', {
|
|
436
440
|
enterTo: 'last-focused'
|
|
437
441
|
});
|
|
438
|
-
(0,
|
|
442
|
+
(0, _container19.setContainerLastFocusedElement)(item, (0, _container19.getContainersForNode)(item));
|
|
439
443
|
var expected = 'second-container';
|
|
440
|
-
var actual = (0,
|
|
444
|
+
var actual = (0, _container19.getContainerConfig)(_container19.rootContainerId).lastFocusedElement;
|
|
441
445
|
expect(actual).toBe(expected);
|
|
442
446
|
}));
|
|
443
447
|
});
|
|
@@ -447,36 +451,36 @@ describe('container', function () {
|
|
|
447
451
|
test('should return element when last focused is not within a subcontainer with enterTo', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
|
|
448
452
|
var index = 3;
|
|
449
453
|
var item = root.querySelectorAll('.spottable').item(index);
|
|
450
|
-
(0,
|
|
451
|
-
(0,
|
|
454
|
+
(0, _container19.setContainerLastFocusedElement)(item, (0, _container19.getContainersForNode)(item));
|
|
455
|
+
(0, _container19.unmountContainer)(_container19.rootContainerId);
|
|
452
456
|
var expected = true;
|
|
453
|
-
var actual = (0,
|
|
457
|
+
var actual = (0, _container19.getContainerConfig)(_container19.rootContainerId).lastFocusedKey.element;
|
|
454
458
|
expect(actual).toBe(expected);
|
|
455
459
|
}));
|
|
456
460
|
test('should return container when last focused is within a subcontainer with enterTo', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
457
|
-
var item = root.querySelectorAll("[".concat(
|
|
458
|
-
(0,
|
|
461
|
+
var item = root.querySelectorAll("[".concat(_container19.containerAttribute, "=\"first-container\"] .spottable")).item(1);
|
|
462
|
+
(0, _container19.configureContainer)('first-container', {
|
|
459
463
|
enterTo: 'last-focused'
|
|
460
464
|
});
|
|
461
|
-
(0,
|
|
462
|
-
(0,
|
|
465
|
+
(0, _container19.setContainerLastFocusedElement)(item, (0, _container19.getContainersForNode)(item));
|
|
466
|
+
(0, _container19.unmountContainer)(_container19.rootContainerId);
|
|
463
467
|
var expected = true;
|
|
464
|
-
var actual = (0,
|
|
468
|
+
var actual = (0, _container19.getContainerConfig)(_container19.rootContainerId).lastFocusedKey.container;
|
|
465
469
|
expect(actual).toBe(expected);
|
|
466
470
|
}));
|
|
467
471
|
test('should save the index of the node when lastFocusedPersist is undefined', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
|
|
468
472
|
var index = 3;
|
|
469
473
|
var item = root.querySelectorAll('.spottable').item(index);
|
|
470
|
-
(0,
|
|
471
|
-
(0,
|
|
474
|
+
(0, _container19.setContainerLastFocusedElement)(item, (0, _container19.getContainersForNode)(item));
|
|
475
|
+
(0, _container19.unmountContainer)(_container19.rootContainerId);
|
|
472
476
|
var expected = index;
|
|
473
|
-
var actual = (0,
|
|
477
|
+
var actual = (0, _container19.getContainerConfig)(_container19.rootContainerId).lastFocusedKey.key;
|
|
474
478
|
expect(actual).toBe(expected);
|
|
475
479
|
}));
|
|
476
480
|
test('should save a custom key for container-configured lastFocusedPersist', (0, _utils.testScenario)(scenarios.onlySpottables, function (root) {
|
|
477
481
|
var index = 3;
|
|
478
482
|
var item = root.querySelectorAll('.spottable').item(3);
|
|
479
|
-
(0,
|
|
483
|
+
(0, _container19.configureContainer)(_container19.rootContainerId, {
|
|
480
484
|
lastFocusedPersist: function lastFocusedPersist(n, all) {
|
|
481
485
|
return {
|
|
482
486
|
element: true,
|
|
@@ -484,36 +488,36 @@ describe('container', function () {
|
|
|
484
488
|
};
|
|
485
489
|
}
|
|
486
490
|
});
|
|
487
|
-
(0,
|
|
488
|
-
(0,
|
|
491
|
+
(0, _container19.setContainerLastFocusedElement)(item, (0, _container19.getContainersForNode)(item));
|
|
492
|
+
(0, _container19.unmountContainer)(_container19.rootContainerId);
|
|
489
493
|
var expected = "item-".concat(index);
|
|
490
|
-
var actual = (0,
|
|
494
|
+
var actual = (0, _container19.getContainerConfig)(_container19.rootContainerId).lastFocusedKey.key;
|
|
491
495
|
expect(actual).toBe(expected);
|
|
492
496
|
}));
|
|
493
497
|
test('should save the container id as the key when a container with enterTo configured had the last focused item', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
494
|
-
var item = root.querySelectorAll("[".concat(
|
|
495
|
-
(0,
|
|
498
|
+
var item = root.querySelectorAll("[".concat(_container19.containerAttribute, "=\"first-container\"] .spottable")).item(1);
|
|
499
|
+
(0, _container19.configureContainer)('first-container', {
|
|
496
500
|
enterTo: 'last-focused'
|
|
497
501
|
});
|
|
498
|
-
(0,
|
|
499
|
-
(0,
|
|
502
|
+
(0, _container19.setContainerLastFocusedElement)(item, (0, _container19.getContainersForNode)(item));
|
|
503
|
+
(0, _container19.unmountContainer)(_container19.rootContainerId);
|
|
500
504
|
var expected = 'first-container';
|
|
501
|
-
var actual = (0,
|
|
505
|
+
var actual = (0, _container19.getContainerConfig)(_container19.rootContainerId).lastFocusedKey.key;
|
|
502
506
|
expect(actual).toBe(expected);
|
|
503
507
|
}));
|
|
504
508
|
test('should save the index as the key when last focused item is only within containers without enterTo configured', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
505
|
-
var item = root.querySelectorAll("[".concat(
|
|
506
|
-
(0,
|
|
507
|
-
(0,
|
|
509
|
+
var item = root.querySelectorAll("[".concat(_container19.containerAttribute, "=\"second-container\"] .spottable")).item(1);
|
|
510
|
+
(0, _container19.setContainerLastFocusedElement)(item, (0, _container19.getContainersForNode)(item));
|
|
511
|
+
(0, _container19.unmountContainer)(_container19.rootContainerId);
|
|
508
512
|
var expected = 4;
|
|
509
|
-
var actual = (0,
|
|
513
|
+
var actual = (0, _container19.getContainerConfig)(_container19.rootContainerId).lastFocusedKey.key;
|
|
510
514
|
expect(actual).toBe(expected);
|
|
511
515
|
}));
|
|
512
516
|
test('should mark the container inactive', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
513
|
-
(0,
|
|
514
|
-
(0,
|
|
517
|
+
(0, _container19.addContainer)('first-container');
|
|
518
|
+
(0, _container19.unmountContainer)('first-container');
|
|
515
519
|
var expected = false;
|
|
516
|
-
var actual = (0,
|
|
520
|
+
var actual = (0, _container19.getContainerConfig)('first-container').active;
|
|
517
521
|
expect(actual).toBe(expected);
|
|
518
522
|
}));
|
|
519
523
|
});
|
|
@@ -521,42 +525,42 @@ describe('container', function () {
|
|
|
521
525
|
beforeEach(setupContainers);
|
|
522
526
|
afterEach(teardownContainers);
|
|
523
527
|
test('should be nearest restrict="self-only" container to current if target is not within it', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
524
|
-
(0,
|
|
528
|
+
(0, _container19.configureContainer)('first-container', {
|
|
525
529
|
restrict: 'self-only'
|
|
526
530
|
});
|
|
527
531
|
var current = root.querySelector('[data-spotlight-id="first-container"] .spottable');
|
|
528
532
|
var target = root.querySelector('.spottable');
|
|
529
|
-
(0,
|
|
533
|
+
(0, _container19.setLastContainerFromTarget)(current, target);
|
|
530
534
|
var expected = 'first-container';
|
|
531
|
-
var actual = (0,
|
|
535
|
+
var actual = (0, _container19.getLastContainer)();
|
|
532
536
|
expect(actual).toBe(expected);
|
|
533
537
|
}));
|
|
534
538
|
test('should be use nearest container to target if within current container', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
535
|
-
(0,
|
|
539
|
+
(0, _container19.configureContainer)('first-container', {
|
|
536
540
|
restrict: 'none'
|
|
537
541
|
});
|
|
538
|
-
(0,
|
|
542
|
+
(0, _container19.configureContainer)('second-container', {
|
|
539
543
|
restrict: 'none'
|
|
540
544
|
});
|
|
541
545
|
var current = root.querySelector('[data-spotlight-id="first-container"] .spottable');
|
|
542
546
|
var target = root.querySelector('[data-spotlight-id="second-container"] .spottable');
|
|
543
|
-
(0,
|
|
547
|
+
(0, _container19.setLastContainerFromTarget)(current, target);
|
|
544
548
|
var expected = 'second-container';
|
|
545
|
-
var actual = (0,
|
|
549
|
+
var actual = (0, _container19.getLastContainer)();
|
|
546
550
|
expect(actual).toBe(expected);
|
|
547
551
|
}));
|
|
548
552
|
test('should target container if it is restrict="self-only" and contains current container', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
549
|
-
(0,
|
|
553
|
+
(0, _container19.configureContainer)('first-container', {
|
|
550
554
|
restrict: 'self-only'
|
|
551
555
|
});
|
|
552
|
-
(0,
|
|
556
|
+
(0, _container19.configureContainer)('second-container', {
|
|
553
557
|
restrict: 'none'
|
|
554
558
|
});
|
|
555
559
|
var current = root.querySelector('[data-spotlight-id="second-container"] .spottable');
|
|
556
560
|
var target = root.querySelector('[data-spotlight-id="first-container"]');
|
|
557
|
-
(0,
|
|
561
|
+
(0, _container19.setLastContainerFromTarget)(current, target);
|
|
558
562
|
var expected = 'first-container';
|
|
559
|
-
var actual = (0,
|
|
563
|
+
var actual = (0, _container19.getLastContainer)();
|
|
560
564
|
expect(actual).toBe(expected);
|
|
561
565
|
}));
|
|
562
566
|
});
|
|
@@ -564,9 +568,9 @@ describe('container', function () {
|
|
|
564
568
|
beforeEach(setupContainers);
|
|
565
569
|
afterEach(teardownContainers);
|
|
566
570
|
test('should return an empty string when container is inactive', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
567
|
-
(0,
|
|
571
|
+
(0, _container19.unmountContainer)(_container19.rootContainerId);
|
|
568
572
|
var expected = '';
|
|
569
|
-
var actual = (0,
|
|
573
|
+
var actual = (0, _container19.getDefaultContainer)();
|
|
570
574
|
expect(actual).toBe(expected);
|
|
571
575
|
}));
|
|
572
576
|
});
|
|
@@ -574,11 +578,11 @@ describe('container', function () {
|
|
|
574
578
|
beforeEach(setupContainers);
|
|
575
579
|
afterEach(teardownContainers);
|
|
576
580
|
test('should return an empty string when container is inactive', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
577
|
-
(0,
|
|
578
|
-
(0,
|
|
579
|
-
(0,
|
|
581
|
+
(0, _container19.addContainer)('first-container');
|
|
582
|
+
(0, _container19.setLastContainer)('first-container');
|
|
583
|
+
(0, _container19.unmountContainer)('first-container');
|
|
580
584
|
var expected = '';
|
|
581
|
-
var actual = (0,
|
|
585
|
+
var actual = (0, _container19.getLastContainer)();
|
|
582
586
|
expect(actual).toBe(expected);
|
|
583
587
|
}));
|
|
584
588
|
});
|
|
@@ -587,10 +591,10 @@ describe('container', function () {
|
|
|
587
591
|
afterEach(teardownContainers);
|
|
588
592
|
test('should not include inacive containers', (0, _utils.testScenario)(scenarios.onlyContainers, function (root) {
|
|
589
593
|
var containerId = root.querySelector('[data-spotlight-id]').dataset.containerId;
|
|
590
|
-
(0,
|
|
591
|
-
(0,
|
|
594
|
+
(0, _container19.addContainer)(containerId);
|
|
595
|
+
(0, _container19.unmountContainer)(containerId);
|
|
592
596
|
var expected = -1;
|
|
593
|
-
var actual = (0,
|
|
597
|
+
var actual = (0, _container19.getAllContainerIds)().indexOf(containerId);
|
|
594
598
|
expect(actual).toBe(expected);
|
|
595
599
|
}));
|
|
596
600
|
});
|
|
@@ -599,7 +603,7 @@ describe('container', function () {
|
|
|
599
603
|
afterEach(teardownContainers);
|
|
600
604
|
test('should return null for an invalid container', (0, _utils.testScenario)(scenarios.onlySpottables, function () {
|
|
601
605
|
var expected = null;
|
|
602
|
-
var actual = (0,
|
|
606
|
+
var actual = (0, _container19.getContainerLastFocusedElement)('does-not-exist');
|
|
603
607
|
expect(actual).toBe(expected);
|
|
604
608
|
}));
|
|
605
609
|
});
|
|
@@ -608,7 +612,7 @@ describe('container', function () {
|
|
|
608
612
|
afterEach(teardownContainers);
|
|
609
613
|
test('should return null for an invalid container', (0, _utils.testScenario)(scenarios.onlySpottables, function () {
|
|
610
614
|
var expected = null;
|
|
611
|
-
var actual = (0,
|
|
615
|
+
var actual = (0, _container19.getContainerDefaultElement)('does-not-exist');
|
|
612
616
|
expect(actual).toBe(expected);
|
|
613
617
|
}));
|
|
614
618
|
});
|
|
@@ -616,16 +620,16 @@ describe('container', function () {
|
|
|
616
620
|
beforeEach(setupContainers);
|
|
617
621
|
afterEach(teardownContainers);
|
|
618
622
|
test('should include all containers when none are restrict="self-only"', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
619
|
-
var expected = [
|
|
620
|
-
var actual = (0,
|
|
623
|
+
var expected = [_container19.rootContainerId, 'first-container', 'second-container'];
|
|
624
|
+
var actual = (0, _container19.getNavigableContainersForNode)(root.querySelector('#secondContainerFirstSpottable'));
|
|
621
625
|
expect(actual).toEqual(expected);
|
|
622
626
|
}));
|
|
623
627
|
test('should include all containers within the first restrict="self-only" container (inclusive)', (0, _utils.testScenario)(scenarios.complexTree, function (root) {
|
|
624
|
-
(0,
|
|
628
|
+
(0, _container19.configureContainer)('first-container', {
|
|
625
629
|
restrict: 'self-only'
|
|
626
630
|
});
|
|
627
631
|
var expected = ['first-container', 'second-container'];
|
|
628
|
-
var actual = (0,
|
|
632
|
+
var actual = (0, _container19.getNavigableContainersForNode)(root.querySelector('#secondContainerFirstSpottable'));
|
|
629
633
|
expect(actual).toEqual(expected);
|
|
630
634
|
}));
|
|
631
635
|
});
|
|
@@ -634,15 +638,30 @@ describe('container', function () {
|
|
|
634
638
|
afterEach(teardownContainers);
|
|
635
639
|
test('should return an empty array for an unconfigured container', (0, _utils.testScenario)(scenarios.complexTree, function () {
|
|
636
640
|
var expected = [];
|
|
637
|
-
var actual = (0,
|
|
641
|
+
var actual = (0, _container19.getContainerNavigableElements)('first-container');
|
|
638
642
|
expect(actual).toEqual(expected);
|
|
639
643
|
}));
|
|
640
644
|
test('should return an empty array for an unmounted, configured container', (0, _utils.testScenario)(scenarios.onlySpottables, function () {
|
|
641
|
-
(0,
|
|
645
|
+
(0, _container19.configureContainer)('first-container', {
|
|
642
646
|
overflow: true
|
|
643
647
|
});
|
|
644
648
|
var expected = [];
|
|
645
|
-
var actual = (0,
|
|
649
|
+
var actual = (0, _container19.getContainerNavigableElements)('first-container');
|
|
650
|
+
expect(actual).toEqual(expected);
|
|
651
|
+
}));
|
|
652
|
+
});
|
|
653
|
+
describe('#getPositionTargetOnFocus', function () {
|
|
654
|
+
beforeEach(setupContainers);
|
|
655
|
+
afterEach(teardownContainers);
|
|
656
|
+
test('should return a container that has positionTargetOnFocus configured', (0, _utils.testScenario)(scenarios.positionTargetOnFocusContainer, function (root) {
|
|
657
|
+
(0, _container19.configureContainer)('positionTargetContainer', {
|
|
658
|
+
positionTargetOnFocus: true
|
|
659
|
+
});
|
|
660
|
+
(0, _container19.configureContainer)('child', {
|
|
661
|
+
enterTo: 'last-focused'
|
|
662
|
+
});
|
|
663
|
+
var expected = root.querySelector('#positionTargetContainer');
|
|
664
|
+
var actual = (0, _container19.getPositionTargetOnFocus)(root.querySelector('#firstChildSpottable'));
|
|
646
665
|
expect(actual).toEqual(expected);
|
|
647
666
|
}));
|
|
648
667
|
});
|