@enact/spotlight 3.4.9-experimental-3 → 3.4.9-experimental-7

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.
Files changed (68) hide show
  1. package/{build/Accelerator → Accelerator}/Accelerator.d.ts +0 -0
  2. package/Accelerator/Accelerator.js +149 -156
  3. package/CHANGELOG.md +22 -0
  4. package/{build/Pause → Pause}/Pause.d.ts +0 -0
  5. package/Pause/Pause.js +102 -80
  6. package/Pause/tests/Pause-specs.js +65 -97
  7. package/SpotlightContainerDecorator/SpotlightContainer.js +175 -140
  8. package/{build/SpotlightContainerDecorator → SpotlightContainerDecorator}/SpotlightContainerDecorator.d.ts +0 -0
  9. package/SpotlightContainerDecorator/SpotlightContainerDecorator.js +222 -176
  10. package/SpotlightContainerDecorator/tests/Element.prototype.closest.js +44 -40
  11. package/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +221 -210
  12. package/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +150 -243
  13. package/SpotlightContainerDecorator/useSpotlightContainer.js +47 -28
  14. package/{build/SpotlightRootDecorator → SpotlightRootDecorator}/SpotlightRootDecorator.d.ts +0 -0
  15. package/SpotlightRootDecorator/SpotlightRootDecorator.js +206 -111
  16. package/{build/Spottable → Spottable}/Spottable.d.ts +0 -0
  17. package/Spottable/Spottable.js +448 -410
  18. package/Spottable/tests/Spottable-specs.js +90 -117
  19. package/package.json +3 -2
  20. package/src/container.js +718 -653
  21. package/src/navigate.js +406 -491
  22. package/src/pointer.js +86 -78
  23. package/{build/src → src}/spotlight.d.ts +0 -0
  24. package/src/spotlight.js +846 -885
  25. package/src/target.js +448 -474
  26. package/src/tests/container-specs.js +643 -1251
  27. package/src/tests/navigate-specs.js +77 -134
  28. package/src/tests/pointer-specs.js +126 -182
  29. package/src/tests/spotlight-specs.js +103 -133
  30. package/src/tests/target-specs.js +597 -960
  31. package/src/tests/utils.js +89 -67
  32. package/src/utils.js +155 -158
  33. package/build/Accelerator/Accelerator.js +0 -162
  34. package/build/Accelerator/package.json +0 -3
  35. package/build/CHANGELOG.md +0 -838
  36. package/build/Pause/Pause.js +0 -164
  37. package/build/Pause/package.json +0 -3
  38. package/build/Pause/tests/Pause-specs.js +0 -65
  39. package/build/README.md +0 -61
  40. package/build/SpotlightContainerDecorator/SpotlightContainer.js +0 -176
  41. package/build/SpotlightContainerDecorator/SpotlightContainerDecorator.js +0 -282
  42. package/build/SpotlightContainerDecorator/package.json +0 -3
  43. package/build/SpotlightContainerDecorator/tests/Element.prototype.closest.js +0 -45
  44. package/build/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +0 -221
  45. package/build/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +0 -160
  46. package/build/SpotlightContainerDecorator/useSpotlightContainer.js +0 -133
  47. package/build/SpotlightRootDecorator/SpotlightRootDecorator.js +0 -189
  48. package/build/SpotlightRootDecorator/package.json +0 -3
  49. package/build/Spottable/Spottable.js +0 -491
  50. package/build/Spottable/package.json +0 -3
  51. package/build/Spottable/tests/Spottable-specs.js +0 -90
  52. package/build/package-lock.json +0 -229
  53. package/build/package.json +0 -28
  54. package/build/src/container.js +0 -1201
  55. package/build/src/navigate.js +0 -419
  56. package/build/src/pointer.js +0 -183
  57. package/build/src/spotlight.js +0 -896
  58. package/build/src/target.js +0 -507
  59. package/build/src/tests/container-specs.js +0 -653
  60. package/build/src/tests/navigate-specs.js +0 -87
  61. package/build/src/tests/pointer-specs.js +0 -130
  62. package/build/src/tests/spotlight-specs.js +0 -112
  63. package/build/src/tests/target-specs.js +0 -614
  64. package/build/src/tests/utils.js +0 -104
  65. package/build/src/utils.js +0 -180
  66. package/build/styles/debug.less +0 -97
  67. package/build/styles/mixins.less +0 -63
  68. package/docs/index.md +0 -364
@@ -1,107 +1,140 @@
1
- /**
2
- * A component for managing groups of spottable components.
3
- *
4
- * @module spotlight/SpotlightContainerDecorator
5
- * @exports SpotlightContainerDecorator
6
- */
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "useSpotlightContainer", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _useSpotlightContainer["default"];
10
+ }
11
+ });
12
+ exports.spotlightDefaultClass = exports.SpotlightContainerDecorator = exports["default"] = void 0;
13
+
14
+ var _handle = _interopRequireWildcard(require("@enact/core/handle"));
15
+
16
+ var _useHandlers = _interopRequireDefault(require("@enact/core/useHandlers"));
17
+
18
+ var _hoc = _interopRequireDefault(require("@enact/core/hoc"));
19
+
20
+ var _react = _interopRequireDefault(require("react"));
21
+
22
+ var _propTypes = _interopRequireDefault(require("prop-types"));
23
+
24
+ var _useSpotlightContainer = _interopRequireDefault(require("./useSpotlightContainer"));
25
+
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
27
+
28
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
29
+
30
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
+
32
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
33
+
34
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
35
+
36
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
37
+
38
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
39
+
40
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
41
+
42
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
43
+
44
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
45
+
46
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
47
+
48
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
49
+
50
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
7
51
 
8
- import handle, {forward} from '@enact/core/handle';
9
- import useHandlers from '@enact/core/useHandlers';
10
- import hoc from '@enact/core/hoc';
11
- import React from 'react';
12
- import PropTypes from 'prop-types';
13
-
14
- import useSpotlightContainer from './useSpotlightContainer';
15
-
16
- const callContext = (name) => (ev, props, context) => context[name](ev, props);
17
- const containerHandlers = {
18
- onMouseEnter: handle(
19
- forward('onMouseEnter'),
20
- callContext('onPointerEnter')
21
- ),
22
- onMouseLeave: handle(
23
- forward('onMouseLeave'),
24
- callContext('onPointerLeave')
25
- ),
26
- onFocusCapture: handle(
27
- callContext('onFocusCapture'),
28
- forward('onFocusCapture')
29
- ),
30
- onBlurCapture: handle(
31
- callContext('onBlurCapture'),
32
- forward('onBlurCapture')
33
- )
52
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
53
+
54
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
55
+
56
+ var callContext = function callContext(name) {
57
+ return function (ev, props, context) {
58
+ return context[name](ev, props);
59
+ };
34
60
  };
35
61
 
62
+ var containerHandlers = {
63
+ onMouseEnter: (0, _handle["default"])((0, _handle.forward)('onMouseEnter'), callContext('onPointerEnter')),
64
+ onMouseLeave: (0, _handle["default"])((0, _handle.forward)('onMouseLeave'), callContext('onPointerLeave')),
65
+ onFocusCapture: (0, _handle["default"])(callContext('onFocusCapture'), (0, _handle.forward)('onFocusCapture')),
66
+ onBlurCapture: (0, _handle["default"])(callContext('onBlurCapture'), (0, _handle.forward)('onBlurCapture'))
67
+ };
36
68
  /**
37
69
  * The class name to apply to the default component to focus in a container.
38
70
  *
39
71
  * @memberof spotlight/SpotlightContainerDecorator
40
72
  * @public
41
73
  */
42
- const spotlightDefaultClass = 'spottable-default';
43
74
 
75
+ var spotlightDefaultClass = 'spottable-default';
44
76
  /**
45
77
  * Default config for {@link spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator}
46
78
  *
47
79
  * @memberof spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator
48
80
  * @hocconfig
49
81
  */
50
- const defaultConfig = {
51
- /**
52
- * When `true`, allows focus to move outside the container to the next spottable element when
53
- * holding 5 way keys.
54
- *
55
- * @type {Boolean}
56
- * @default false
57
- * @memberof spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.defaultConfig
58
- * @public
59
- */
60
- continue5WayHold: false,
61
-
62
- /**
63
- * The selector for the default spottable element within the container.
64
- *
65
- * @type {String}
66
- * @default '.spottable-default'
67
- * @memberof spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.defaultConfig
68
- * @public
69
- */
70
- defaultElement: `.${spotlightDefaultClass}`,
71
-
72
- /**
73
- * Directs which element receives focus when gaining focus from another container. If
74
- * `'default-element'`, the default focused item will be selected. If `'last-focused'`, the
75
- * container will focus the last focused item; if the container has never had focus, the default
76
- * element will receive focus. If `null`, the default 5-way behavior will be applied.
77
- *
78
- * @type {String}
79
- * @default null
80
- * @memberof spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.defaultConfig
81
- * @public
82
- */
83
- enterTo: null,
84
-
85
- /**
86
- * Filter the navigable elements.
87
- *
88
- * @type {Function}
89
- * @memberof spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.defaultConfig
90
- * @public
91
- */
92
- navigableFilter: null,
93
-
94
- /**
95
- * Whether the container will preserve the specified `spotlightId` when it unmounts.
96
- *
97
- * @type {Boolean}
98
- * @default false
99
- * @memberof spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.defaultConfig
100
- * @public
101
- */
102
- preserveId: false
103
- };
104
82
 
83
+ exports.spotlightDefaultClass = spotlightDefaultClass;
84
+ var defaultConfig = {
85
+ /**
86
+ * When `true`, allows focus to move outside the container to the next spottable element when
87
+ * holding 5 way keys.
88
+ *
89
+ * @type {Boolean}
90
+ * @default false
91
+ * @memberof spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.defaultConfig
92
+ * @public
93
+ */
94
+ continue5WayHold: false,
95
+
96
+ /**
97
+ * The selector for the default spottable element within the container.
98
+ *
99
+ * @type {String}
100
+ * @default '.spottable-default'
101
+ * @memberof spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.defaultConfig
102
+ * @public
103
+ */
104
+ defaultElement: ".".concat(spotlightDefaultClass),
105
+
106
+ /**
107
+ * Directs which element receives focus when gaining focus from another container. If
108
+ * `'default-element'`, the default focused item will be selected. If `'last-focused'`, the
109
+ * container will focus the last focused item; if the container has never had focus, the default
110
+ * element will receive focus. If `null`, the default 5-way behavior will be applied.
111
+ *
112
+ * @type {String}
113
+ * @default null
114
+ * @memberof spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.defaultConfig
115
+ * @public
116
+ */
117
+ enterTo: null,
118
+
119
+ /**
120
+ * Filter the navigable elements.
121
+ *
122
+ * @type {Function}
123
+ * @memberof spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.defaultConfig
124
+ * @public
125
+ */
126
+ navigableFilter: null,
127
+
128
+ /**
129
+ * Whether the container will preserve the specified `spotlightId` when it unmounts.
130
+ *
131
+ * @type {Boolean}
132
+ * @default false
133
+ * @memberof spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.defaultConfig
134
+ * @public
135
+ */
136
+ preserveId: false
137
+ };
105
138
  /**
106
139
  * Constructs a higher-order component that allows Spotlight focus to be passed to its own
107
140
  * configurable hierarchy of spottable child controls.
@@ -144,93 +177,106 @@ const defaultConfig = {
144
177
  * @memberof spotlight/SpotlightContainerDecorator
145
178
  * @hoc
146
179
  */
147
- const SpotlightContainerDecorator = hoc(defaultConfig, (config, Wrapped) => {
148
- const {navigableFilter, preserveId, ...containerConfig} = config;
149
-
150
- // eslint-disable-next-line no-shadow
151
- function SpotlightContainerDecorator (props) {
152
- const {spotlightDisabled, spotlightId, spotlightMuted, spotlightRestrict, ...rest} = props;
153
-
154
- const spotlightContainer = useSpotlightContainer({
155
- id: spotlightId,
156
- muted: spotlightMuted,
157
- disabled: spotlightDisabled,
158
- restrict: spotlightRestrict,
159
-
160
- containerConfig, // continue5WayHold, defaultElement, and enterTo can be in the containerConfig object.
161
- navigableFilter,
162
- preserveId
163
- });
164
- const handlers = useHandlers(containerHandlers, props, spotlightContainer);
165
-
166
- return (
167
- <Wrapped {...rest} {...spotlightContainer.attributes} {...handlers} />
168
- );
169
- }
170
-
171
- SpotlightContainerDecorator.propTypes = /** @lends spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.prototype */ {
172
- /**
173
- * When `true`, controls in the container cannot be navigated.
174
- *
175
- * @type {Boolean}
176
- * @default false
177
- * @public
178
- */
179
- spotlightDisabled: PropTypes.bool,
180
-
181
- /**
182
- * Used to identify this component within the Spotlight system.
183
- *
184
- * If the value is `null`, an id will be generated.
185
- *
186
- * @type {String}
187
- * @public
188
- */
189
- spotlightId: PropTypes.string,
190
-
191
- /**
192
- * Whether or not the container is in muted mode.
193
- *
194
- * @type {Boolean}
195
- * @default false
196
- * @public
197
- */
198
- spotlightMuted: PropTypes.bool,
199
-
200
- /**
201
- * Restricts or prioritizes navigation when focus attempts to leave the container. It
202
- * can be either 'none', 'self-first', or 'self-only'. Specifying 'self-first' indicates that
203
- * elements within the container will have a higher likelihood to be chosen as the next
204
- * navigable element. Specifying 'self-only' indicates that elements in other containers
205
- * cannot be navigated to by using 5-way navigation - however, elements in other containers
206
- * can still receive focus by calling `Spotlight.focus(elem)` explicitly. Specifying 'none'
207
- * indicates there should be no restrictions when 5-way navigating the container.
208
- *
209
- * @type {String}
210
- * @public
211
- */
212
- spotlightRestrict: PropTypes.oneOf(['none', 'self-first', 'self-only'])
213
- };
214
-
215
- SpotlightContainerDecorator.defaultProps = {
216
- spotlightDisabled: false,
217
- spotlightMuted: false,
218
- spotlightRestrict: 'self-first'
219
- };
220
-
221
- // Wrapping with a React.Component to maintain ref support
222
- return class SpotlightContainerDecoratorAdapter extends React.Component {
223
- render () {
224
- return (
225
- <SpotlightContainerDecorator {...this.props} />
226
- );
227
- }
228
- };
229
- });
230
180
 
231
- export default SpotlightContainerDecorator;
232
- export {
233
- SpotlightContainerDecorator,
234
- spotlightDefaultClass,
235
- useSpotlightContainer
236
- };
181
+ var SpotlightContainerDecorator = (0, _hoc["default"])(defaultConfig, function (config, Wrapped) {
182
+ var navigableFilter = config.navigableFilter,
183
+ preserveId = config.preserveId,
184
+ containerConfig = _objectWithoutProperties(config, ["navigableFilter", "preserveId"]); // eslint-disable-next-line no-shadow
185
+
186
+
187
+ function SpotlightContainerDecorator(props) {
188
+ var spotlightDisabled = props.spotlightDisabled,
189
+ spotlightId = props.spotlightId,
190
+ spotlightMuted = props.spotlightMuted,
191
+ spotlightRestrict = props.spotlightRestrict,
192
+ rest = _objectWithoutProperties(props, ["spotlightDisabled", "spotlightId", "spotlightMuted", "spotlightRestrict"]);
193
+
194
+ var spotlightContainer = (0, _useSpotlightContainer["default"])({
195
+ id: spotlightId,
196
+ muted: spotlightMuted,
197
+ disabled: spotlightDisabled,
198
+ restrict: spotlightRestrict,
199
+ containerConfig: containerConfig,
200
+ // continue5WayHold, defaultElement, and enterTo can be in the containerConfig object.
201
+ navigableFilter: navigableFilter,
202
+ preserveId: preserveId
203
+ });
204
+ var handlers = (0, _useHandlers["default"])(containerHandlers, props, spotlightContainer);
205
+ return /*#__PURE__*/_react["default"].createElement(Wrapped, Object.assign({}, rest, spotlightContainer.attributes, handlers));
206
+ }
207
+
208
+ SpotlightContainerDecorator.propTypes =
209
+ /** @lends spotlight/SpotlightContainerDecorator.SpotlightContainerDecorator.prototype */
210
+ {
211
+ /**
212
+ * When `true`, controls in the container cannot be navigated.
213
+ *
214
+ * @type {Boolean}
215
+ * @default false
216
+ * @public
217
+ */
218
+ spotlightDisabled: _propTypes["default"].bool,
219
+
220
+ /**
221
+ * Used to identify this component within the Spotlight system.
222
+ *
223
+ * If the value is `null`, an id will be generated.
224
+ *
225
+ * @type {String}
226
+ * @public
227
+ */
228
+ spotlightId: _propTypes["default"].string,
229
+
230
+ /**
231
+ * Whether or not the container is in muted mode.
232
+ *
233
+ * @type {Boolean}
234
+ * @default false
235
+ * @public
236
+ */
237
+ spotlightMuted: _propTypes["default"].bool,
238
+
239
+ /**
240
+ * Restricts or prioritizes navigation when focus attempts to leave the container. It
241
+ * can be either 'none', 'self-first', or 'self-only'. Specifying 'self-first' indicates that
242
+ * elements within the container will have a higher likelihood to be chosen as the next
243
+ * navigable element. Specifying 'self-only' indicates that elements in other containers
244
+ * cannot be navigated to by using 5-way navigation - however, elements in other containers
245
+ * can still receive focus by calling `Spotlight.focus(elem)` explicitly. Specifying 'none'
246
+ * indicates there should be no restrictions when 5-way navigating the container.
247
+ *
248
+ * @type {String}
249
+ * @public
250
+ */
251
+ spotlightRestrict: _propTypes["default"].oneOf(['none', 'self-first', 'self-only'])
252
+ };
253
+ SpotlightContainerDecorator.defaultProps = {
254
+ spotlightDisabled: false,
255
+ spotlightMuted: false,
256
+ spotlightRestrict: 'self-first'
257
+ }; // Wrapping with a React.Component to maintain ref support
258
+
259
+ return /*#__PURE__*/function (_React$Component) {
260
+ _inherits(SpotlightContainerDecoratorAdapter, _React$Component);
261
+
262
+ var _super = _createSuper(SpotlightContainerDecoratorAdapter);
263
+
264
+ function SpotlightContainerDecoratorAdapter() {
265
+ _classCallCheck(this, SpotlightContainerDecoratorAdapter);
266
+
267
+ return _super.apply(this, arguments);
268
+ }
269
+
270
+ _createClass(SpotlightContainerDecoratorAdapter, [{
271
+ key: "render",
272
+ value: function render() {
273
+ return /*#__PURE__*/_react["default"].createElement(SpotlightContainerDecorator, this.props);
274
+ }
275
+ }]);
276
+
277
+ return SpotlightContainerDecoratorAdapter;
278
+ }(_react["default"].Component);
279
+ });
280
+ exports.SpotlightContainerDecorator = SpotlightContainerDecorator;
281
+ var _default = SpotlightContainerDecorator;
282
+ exports["default"] = _default;
@@ -1,41 +1,45 @@
1
- /* global Element */
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = _default;
2
7
 
3
- export default function (set, remove) {
4
- let polyfilled = false;
5
-
6
- set(() => {
7
- if (!Element.prototype.closest) {
8
- polyfilled = true;
9
-
10
- // we're using detached nodes so we have to find the root node rather than the document
11
- function findRoot (n) {
12
- while (n && n.parentNode) {
13
- n = n.parentNode;
14
- }
15
-
16
- return n;
17
- }
18
-
19
- Element.prototype.closest = function (s) {
20
- let matches = findRoot(this).querySelectorAll(s),
21
- i,
22
- el = this;
23
-
24
- do {
25
- i = matches.length;
26
- while (--i >= 0 && matches.item(i) !== el) {
27
- // nothing
28
- }
29
- } while ((i < 0) && (el = el.parentElement));
30
-
31
- return el;
32
- };
33
- }
34
- });
35
-
36
- remove(() => {
37
- if (polyfilled) {
38
- delete Element.prototype.closest;
39
- }
40
- });
41
- }
8
+ /* global Element */
9
+ function _default(set, remove) {
10
+ var polyfilled = false;
11
+ set(function () {
12
+ if (!Element.prototype.closest) {
13
+ // we're using detached nodes so we have to find the root node rather than the document
14
+ var findRoot = function findRoot(n) {
15
+ while (n && n.parentNode) {
16
+ n = n.parentNode;
17
+ }
18
+
19
+ return n;
20
+ };
21
+
22
+ polyfilled = true;
23
+
24
+ Element.prototype.closest = function (s) {
25
+ var matches = findRoot(this).querySelectorAll(s),
26
+ i,
27
+ el = this;
28
+
29
+ do {
30
+ i = matches.length;
31
+
32
+ while (--i >= 0 && matches.item(i) !== el) {// nothing
33
+ }
34
+ } while (i < 0 && (el = el.parentElement));
35
+
36
+ return el;
37
+ };
38
+ }
39
+ });
40
+ remove(function () {
41
+ if (polyfilled) {
42
+ delete Element.prototype.closest;
43
+ }
44
+ });
45
+ }