@whitesev/domutils 1.3.8 → 1.4.0

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.js CHANGED
@@ -1,11 +1,55 @@
1
1
  'use strict';
2
2
 
3
+ class WindowApi {
4
+ /** 默认的配置 */
5
+ defaultApi = {
6
+ document: document,
7
+ window: window,
8
+ globalThis: globalThis,
9
+ self: self,
10
+ top: top,
11
+ };
12
+ /** 使用的配置 */
13
+ api;
14
+ constructor(option) {
15
+ if (option) {
16
+ if (option.globalThis == null) {
17
+ option.globalThis = option.window;
18
+ }
19
+ if (option.self == null) {
20
+ option.self = option.window;
21
+ }
22
+ }
23
+ if (!option) {
24
+ option = Object.assign({}, this.defaultApi);
25
+ }
26
+ // @ts-ignore
27
+ this.api = Object.assign({}, option);
28
+ }
29
+ get document() {
30
+ return this.api.document;
31
+ }
32
+ get window() {
33
+ return this.api.window;
34
+ }
35
+ get globalThis() {
36
+ return this.api.globalThis;
37
+ }
38
+ get self() {
39
+ return this.api.self;
40
+ }
41
+ get top() {
42
+ return this.api.top;
43
+ }
44
+ }
45
+
3
46
  /** 通用工具类 */
4
47
  const DOMUtilsCommonUtils = {
5
- windowApi: {
6
- window: window,
48
+ windowApi: new WindowApi({
7
49
  document: document,
8
- },
50
+ window: window,
51
+ top: top,
52
+ }),
9
53
  /**
10
54
  * 判断元素是否已显示或已连接
11
55
  * @param element
@@ -111,7 +155,7 @@ const DOMUtilsCommonUtils = {
111
155
 
112
156
  /* 数据 */
113
157
  const DOMUtilsData = {
114
- /** .on绑定的事件 */
158
+ /** .on添加在元素存储的事件 */
115
159
  SymbolEvents: Symbol("events_" + (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)),
116
160
  };
117
161
 
@@ -121,40 +165,6 @@ const OriginPrototype = {
121
165
  },
122
166
  };
123
167
 
124
- class WindowApi {
125
- /** 默认的配置 */
126
- defaultApi = {
127
- document: document,
128
- window: window,
129
- globalThis: globalThis,
130
- self: self,
131
- top: top,
132
- };
133
- /** 使用的配置 */
134
- api;
135
- constructor(option) {
136
- if (!option) {
137
- option = Object.assign({}, this.defaultApi);
138
- }
139
- this.api = Object.assign({}, option);
140
- }
141
- get document() {
142
- return this.api.document;
143
- }
144
- get window() {
145
- return this.api.window;
146
- }
147
- get globalThis() {
148
- return this.api.globalThis;
149
- }
150
- get self() {
151
- return this.api.self;
152
- }
153
- get top() {
154
- return this.api.top;
155
- }
156
- }
157
-
158
168
  class DOMUtilsEvent {
159
169
  windowApi;
160
170
  constructor(windowApiOption) {
@@ -967,7 +977,7 @@ class DOMUtils extends DOMUtilsEvent {
967
977
  super(option);
968
978
  }
969
979
  /** 版本号 */
970
- version = "2024.10.23";
980
+ version = "2024.11.6";
971
981
  attr(element, attrName, attrValue) {
972
982
  let DOMUtilsContext = this;
973
983
  if (typeof element === "string") {