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