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