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