@dnd-kit/dom 0.1.11 → 0.1.12-beta-20250507113354

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/index.cjs CHANGED
@@ -218,42 +218,57 @@ var Accessibility = class extends abstract.Plugin {
218
218
  liveRegionElement.appendChild(liveRegionTextNode);
219
219
  document.body.append(hiddenTextElement, liveRegionElement);
220
220
  };
221
- const updateAttributes = () => {
221
+ const mutations = /* @__PURE__ */ new Set();
222
+ function executeMutations() {
223
+ for (const operation of mutations) {
224
+ operation();
225
+ }
226
+ }
227
+ this.registerEffect(() => {
222
228
  var _a4;
229
+ mutations.clear();
223
230
  for (const draggable of this.manager.registry.draggables.value) {
224
231
  const activator = (_a4 = draggable.handle) != null ? _a4 : draggable.element;
225
232
  if (activator) {
226
- if (!hiddenTextElement || !liveRegionElement) {
227
- initialize();
228
- }
233
+ mutations.add(initialize);
229
234
  if ((!isFocusable(activator) || utilities.isSafari()) && !activator.hasAttribute("tabindex")) {
230
- activator.setAttribute("tabindex", "0");
235
+ mutations.add(() => activator.setAttribute("tabindex", "0"));
231
236
  }
232
237
  if (!activator.hasAttribute("role") && !(activator.tagName.toLowerCase() === "button")) {
233
- activator.setAttribute("role", defaultAttributes.role);
238
+ mutations.add(
239
+ () => activator.setAttribute("role", defaultAttributes.role)
240
+ );
234
241
  }
235
- if (!activator.hasAttribute("role-description")) {
236
- activator.setAttribute(
237
- "aria-roledescription",
238
- defaultAttributes.roleDescription
242
+ if (!activator.hasAttribute("aria-roledescription")) {
243
+ mutations.add(
244
+ () => activator.setAttribute(
245
+ "aria-roledescription",
246
+ defaultAttributes.roleDescription
247
+ )
239
248
  );
240
249
  }
241
250
  if (!activator.hasAttribute("aria-describedby")) {
242
- activator.setAttribute("aria-describedby", descriptionId);
251
+ mutations.add(
252
+ () => activator.setAttribute("aria-describedby", descriptionId)
253
+ );
243
254
  }
244
255
  for (const key of ["aria-pressed", "aria-grabbed"]) {
245
- activator.setAttribute(key, String(draggable.isDragging));
256
+ const value = String(draggable.isDragging);
257
+ if (activator.getAttribute(key) !== value) {
258
+ mutations.add(() => activator.setAttribute(key, value));
259
+ }
260
+ }
261
+ const disabled = String(draggable.disabled);
262
+ if (activator.getAttribute("aria-disabled") !== disabled) {
263
+ mutations.add(
264
+ () => activator.setAttribute("aria-disabled", disabled)
265
+ );
246
266
  }
247
- activator.setAttribute("aria-disabled", String(draggable.disabled));
248
267
  }
249
268
  }
250
- };
251
- this.registerEffect(() => {
252
- for (const draggable of this.manager.registry.draggables.value) {
253
- void draggable.element;
254
- void draggable.handle;
269
+ if (mutations.size > 0) {
270
+ utilities.scheduler.schedule(executeMutations);
255
271
  }
256
- utilities.scheduler.schedule(updateAttributes);
257
272
  });
258
273
  this.destroy = () => {
259
274
  super.destroy();
@@ -1140,9 +1155,13 @@ var Scheduler = class {
1140
1155
  return new Promise((resolve) => this.resolvers.add(resolve));
1141
1156
  }
1142
1157
  };
1143
- var scheduler3 = new Scheduler(
1144
- (callback) => requestAnimationFrame(callback)
1145
- );
1158
+ var scheduler3 = new Scheduler((callback) => {
1159
+ if (typeof requestAnimationFrame === "function") {
1160
+ requestAnimationFrame(callback);
1161
+ } else {
1162
+ callback();
1163
+ }
1164
+ });
1146
1165
 
1147
1166
  // src/core/plugins/scrolling/AutoScroller.ts
1148
1167
  var AUTOSCROLL_INTERVAL = 10;