@tb-dev/prototype-dom 6.1.3 → 6.1.5

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 +8 -15
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -98,27 +98,20 @@
98
98
  if (element)
99
99
  return Promise.resolve(element);
100
100
  return new Promise((resolve, reject) => {
101
- let timeout = null;
102
- let interval = null;
103
- function onElementFound(el) {
104
- if (typeof timeout === 'number')
105
- clearTimeout(timeout);
106
- if (typeof interval === 'number')
107
- clearInterval(interval);
108
- resolve(el);
109
- }
101
+ const timeout = setTimeout(onTimeout, timeoutMillis);
102
+ const interval = setInterval(onInterval.bind(this), 50);
110
103
  function onInterval() {
111
104
  element = this.querySelector(selector);
112
- if (element)
113
- onElementFound(element);
105
+ if (element) {
106
+ clearInterval(interval);
107
+ clearTimeout(timeout);
108
+ resolve(element);
109
+ }
114
110
  }
115
111
  function onTimeout() {
116
- if (typeof interval === 'number')
117
- clearInterval(interval);
112
+ clearInterval(interval);
118
113
  reject(new Error(`timeout waiting for element: ${selector}`));
119
114
  }
120
- interval = setInterval(onInterval.bind(this), 50);
121
- timeout = setTimeout(onTimeout, timeoutMillis);
122
115
  });
123
116
  };
124
117
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-dev/prototype-dom",
3
- "version": "6.1.3",
3
+ "version": "6.1.5",
4
4
  "description": "Adds prototype methods to DOM objects",
5
5
  "packageManager": "pnpm@8.15.4",
6
6
  "license": "MIT",
@@ -24,16 +24,16 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@rollup/plugin-typescript": "^11.1.6",
27
- "@tb-dev/eslint-config": "^2.1.1",
27
+ "@tb-dev/eslint-config": "^3.0.2",
28
28
  "eslint": "^8.57.0",
29
29
  "husky": "^9.0.11",
30
30
  "lint-staged": "^15.2.2",
31
31
  "prettier": "^3.2.5",
32
- "rollup": "^4.12.0",
32
+ "rollup": "^4.13.0",
33
33
  "tslib": "^2.6.2",
34
- "typedoc": "^0.25.9",
35
- "typedoc-plugin-mdn-links": "^3.1.17",
36
- "typescript": "5.3.3"
34
+ "typedoc": "^0.25.12",
35
+ "typedoc-plugin-mdn-links": "^3.1.18",
36
+ "typescript": "^5.4.2"
37
37
  },
38
38
  "files": [
39
39
  "dist/**/*"