@tb-dev/prototype-dom 6.1.6 → 6.1.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 (2) hide show
  1. package/dist/index.js +15 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -93,26 +93,26 @@
93
93
  };
94
94
  }
95
95
  function waitChild() {
96
- return function (selector, timeoutMillis = 300_000) {
96
+ return function (selector, timeoutMillis = 60_000) {
97
97
  let element = this.querySelector(selector);
98
98
  if (element)
99
99
  return Promise.resolve(element);
100
- return new Promise((resolve, reject) => {
101
- const timeout = setTimeout(onTimeout, timeoutMillis);
102
- const interval = setInterval(onInterval.bind(this), 50);
103
- function onInterval() {
104
- element = this.querySelector(selector);
105
- if (element) {
106
- clearInterval(interval);
107
- clearTimeout(timeout);
108
- resolve(element);
109
- }
110
- }
111
- function onTimeout() {
100
+ const { promise, resolve, reject } = Promise.withResolvers();
101
+ const timeout = setTimeout(onTimeout, timeoutMillis);
102
+ const interval = setInterval(onInterval.bind(this), 20);
103
+ function onInterval() {
104
+ element = this.querySelector(selector);
105
+ if (element) {
112
106
  clearInterval(interval);
113
- reject(new Error(`timeout waiting for element: ${selector}`));
107
+ clearTimeout(timeout);
108
+ resolve(element);
114
109
  }
115
- });
110
+ }
111
+ function onTimeout() {
112
+ clearInterval(interval);
113
+ reject(new Error(`timeout waiting for element: ${selector}`));
114
+ }
115
+ return promise;
116
116
  };
117
117
  }
118
118
  const element = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/prototype-dom",
3
- "version": "6.1.6",
3
+ "version": "6.1.7",
4
4
  "description": "Adds prototype methods to DOM objects",
5
5
  "packageManager": "pnpm@8.15.4",
6
6
  "license": "MIT",