@ctrl/dom 0.1.1 → 0.1.2

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.
@@ -1256,10 +1256,14 @@ if (typeof globalThis.setImmediate === "function") observeTimerGlobals();
1256
1256
  function markTimers(config) {
1257
1257
  if (config.delay === 0 && config.advanceTimers === defaultAdvanceTimers) observeTimerGlobals();
1258
1258
  }
1259
- function canYieldWithImmediate(config) {
1259
+ /** `delay: 0`, the default `advanceTimers`, and real timers: nothing replaced or faked. */
1260
+ function realTimersAtZeroDelay(config) {
1260
1261
  if (config.delay !== 0 || config.advanceTimers !== defaultAdvanceTimers) return false;
1261
1262
  const setImmediate = globalThis.setImmediate;
1262
- if (typeof setImmediate !== "function" || isFaked(setImmediate) || !timerGlobalsObserved()) return false;
1263
+ return typeof setImmediate === "function" && !isFaked(setImmediate) && timerGlobalsObserved();
1264
+ }
1265
+ function canYieldWithImmediate(config) {
1266
+ if (!realTimersAtZeroDelay(config)) return false;
1263
1267
  if (trackedTimerDueSoon()) return false;
1264
1268
  const untracked = untrackedTimeouts();
1265
1269
  if (untracked === -1 || untrackedBaseline === -1 || untracked > untrackedBaseline) return false;
@@ -1275,7 +1279,7 @@ async function yieldBetweenActions(config) {
1275
1279
  await wait(config);
1276
1280
  if (timerGlobalsObserved()) untrackedBaseline = untrackedTimeouts();
1277
1281
  }
1278
- if (config.delay === 0 && !isFaked(globalThis.setImmediate)) for (let hop = 0; hop < MAX_YIELD_HOPS && immediatesPending(); hop++) await new Promise(resolveOnImmediate);
1282
+ if (realTimersAtZeroDelay(config)) for (let hop = 0; hop < MAX_YIELD_HOPS && immediatesPending(); hop++) await new Promise(resolveOnImmediate);
1279
1283
  }
1280
1284
 
1281
1285
  // src/system/pointer/shared.ts
@@ -1233,10 +1233,14 @@ if (typeof globalThis.setImmediate === "function") observeTimerGlobals();
1233
1233
  function markTimers(config) {
1234
1234
  if (config.delay === 0 && config.advanceTimers === defaultAdvanceTimers) observeTimerGlobals();
1235
1235
  }
1236
- function canYieldWithImmediate(config) {
1236
+ /** `delay: 0`, the default `advanceTimers`, and real timers: nothing replaced or faked. */
1237
+ function realTimersAtZeroDelay(config) {
1237
1238
  if (config.delay !== 0 || config.advanceTimers !== defaultAdvanceTimers) return false;
1238
1239
  const setImmediate = globalThis.setImmediate;
1239
- if (typeof setImmediate !== "function" || isFaked(setImmediate) || !timerGlobalsObserved()) return false;
1240
+ return typeof setImmediate === "function" && !isFaked(setImmediate) && timerGlobalsObserved();
1241
+ }
1242
+ function canYieldWithImmediate(config) {
1243
+ if (!realTimersAtZeroDelay(config)) return false;
1240
1244
  if (trackedTimerDueSoon()) return false;
1241
1245
  const untracked = untrackedTimeouts();
1242
1246
  if (untracked === -1 || untrackedBaseline === -1 || untracked > untrackedBaseline) return false;
@@ -1252,7 +1256,7 @@ async function yieldBetweenActions(config) {
1252
1256
  await wait(config);
1253
1257
  if (timerGlobalsObserved()) untrackedBaseline = untrackedTimeouts();
1254
1258
  }
1255
- if (config.delay === 0 && !isFaked(globalThis.setImmediate)) for (let hop = 0; hop < MAX_YIELD_HOPS && immediatesPending(); hop++) await new Promise(resolveOnImmediate);
1259
+ if (realTimersAtZeroDelay(config)) for (let hop = 0; hop < MAX_YIELD_HOPS && immediatesPending(); hop++) await new Promise(resolveOnImmediate);
1256
1260
  }
1257
1261
 
1258
1262
  // src/system/pointer/shared.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl/dom",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "A fast DOM for testing React components: a drop-in replacement for jsdom and happy-dom, with Testing Library, user-event and jest-dom built in.",
5
5
  "keywords": [
6
6
  "dom",