power-focusable 2.1.9 → 2.1.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/dist/index.cjs CHANGED
@@ -75,8 +75,7 @@ function isFocusable(element) {
75
75
  if (element.hasAttribute("hidden") || element.hasAttribute("inert")) {
76
76
  return false;
77
77
  }
78
- const index = element.getAttribute("tabindex");
79
- if (index && Number(index) < 0) {
78
+ if (element.tabIndex < 0) {
80
79
  return false;
81
80
  }
82
81
  if (!element.matches(FOCUSABLE_SELECTOR)) {
@@ -135,16 +134,6 @@ function getActiveElement() {
135
134
  }
136
135
  return current;
137
136
  }
138
- var tabIndexCache = /* @__PURE__ */ new WeakMap();
139
- function getTabIndex(element) {
140
- const cached = tabIndexCache.get(element);
141
- if (cached !== void 0) {
142
- return cached;
143
- }
144
- const index = Number(element.getAttribute("tabindex"));
145
- tabIndexCache.set(element, index);
146
- return index;
147
- }
148
137
  function isDisabled(element) {
149
138
  return "disabled" in element && !!element.disabled;
150
139
  }
@@ -219,10 +208,10 @@ function sortByTabIndex(elements) {
219
208
  const natural = [];
220
209
  for (let i = 0, l = elements.length; i < l; i++) {
221
210
  const element = elements[i];
222
- const target = getTabIndex(element) > 0 ? ordered : natural;
211
+ const target = element.tabIndex > 0 ? ordered : natural;
223
212
  target[target.length] = element;
224
213
  }
225
- ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b));
214
+ ordered.sort((a, b) => a.tabIndex - b.tabIndex);
226
215
  let count = 0;
227
216
  const sorted = new Array(ordered.length + natural.length);
228
217
  for (let i = 0, l = ordered.length; i < l; i++) {
@@ -238,7 +227,7 @@ function sortByTabIndex(elements) {
238
227
  * High-precision focus management utility with shadow DOM support.
239
228
  * Handles complex focus rules including tabindex ordering, radio groups, etc.
240
229
  *
241
- * @version 2.1.9
230
+ * @version 2.1.10
242
231
  * @author Yusuke Kamiyamane
243
232
  * @license MIT
244
233
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@
3
3
  * High-precision focus management utility with shadow DOM support.
4
4
  * Handles complex focus rules including tabindex ordering, radio groups, etc.
5
5
  *
6
- * @version 2.1.9
6
+ * @version 2.1.10
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * High-precision focus management utility with shadow DOM support.
4
4
  * Handles complex focus rules including tabindex ordering, radio groups, etc.
5
5
  *
6
- * @version 2.1.9
6
+ * @version 2.1.10
7
7
  * @author Yusuke Kamiyamane
8
8
  * @license MIT
9
9
  * @copyright Copyright (c) Yusuke Kamiyamane
package/dist/index.js CHANGED
@@ -73,8 +73,7 @@ function isFocusable(element) {
73
73
  if (element.hasAttribute("hidden") || element.hasAttribute("inert")) {
74
74
  return false;
75
75
  }
76
- const index = element.getAttribute("tabindex");
77
- if (index && Number(index) < 0) {
76
+ if (element.tabIndex < 0) {
78
77
  return false;
79
78
  }
80
79
  if (!element.matches(FOCUSABLE_SELECTOR)) {
@@ -133,16 +132,6 @@ function getActiveElement() {
133
132
  }
134
133
  return current;
135
134
  }
136
- var tabIndexCache = /* @__PURE__ */ new WeakMap();
137
- function getTabIndex(element) {
138
- const cached = tabIndexCache.get(element);
139
- if (cached !== void 0) {
140
- return cached;
141
- }
142
- const index = Number(element.getAttribute("tabindex"));
143
- tabIndexCache.set(element, index);
144
- return index;
145
- }
146
135
  function isDisabled(element) {
147
136
  return "disabled" in element && !!element.disabled;
148
137
  }
@@ -217,10 +206,10 @@ function sortByTabIndex(elements) {
217
206
  const natural = [];
218
207
  for (let i = 0, l = elements.length; i < l; i++) {
219
208
  const element = elements[i];
220
- const target = getTabIndex(element) > 0 ? ordered : natural;
209
+ const target = element.tabIndex > 0 ? ordered : natural;
221
210
  target[target.length] = element;
222
211
  }
223
- ordered.sort((a, b) => getTabIndex(a) - getTabIndex(b));
212
+ ordered.sort((a, b) => a.tabIndex - b.tabIndex);
224
213
  let count = 0;
225
214
  const sorted = new Array(ordered.length + natural.length);
226
215
  for (let i = 0, l = ordered.length; i < l; i++) {
@@ -236,7 +225,7 @@ function sortByTabIndex(elements) {
236
225
  * High-precision focus management utility with shadow DOM support.
237
226
  * Handles complex focus rules including tabindex ordering, radio groups, etc.
238
227
  *
239
- * @version 2.1.9
228
+ * @version 2.1.10
240
229
  * @author Yusuke Kamiyamane
241
230
  * @license MIT
242
231
  * @copyright Copyright (c) Yusuke Kamiyamane
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "power-focusable",
3
- "version": "2.1.9",
3
+ "version": "2.1.10",
4
4
  "description": "High-precision focus management utility with shadow DOM support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",