@whitesev/domutils 1.5.1 → 1.5.2
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.amd.js +22 -33
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +22 -33
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +22 -33
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +22 -33
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +22 -33
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +22 -33
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/DOMUtils.ts +21 -20
package/dist/index.system.js
CHANGED
|
@@ -83,22 +83,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
83
83
|
*/
|
|
84
84
|
setSafeHTML($el, text) {
|
|
85
85
|
// 创建 TrustedHTML 策略(需 CSP 允许)
|
|
86
|
-
|
|
87
|
-
$el.innerHTML = text;
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
// @ts-ignore
|
|
91
|
-
if (globalThis.trustedTypes) {
|
|
92
|
-
// @ts-ignore
|
|
93
|
-
const policy = globalThis.trustedTypes.createPolicy("safe-innerHTML", {
|
|
94
|
-
createHTML: (html) => html,
|
|
95
|
-
});
|
|
96
|
-
$el.innerHTML = policy.createHTML(text);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
throw new Error("trustedTypes is not defined");
|
|
100
|
-
}
|
|
101
|
-
}
|
|
86
|
+
$el.innerHTML = this.getSafeHTML(text);
|
|
102
87
|
},
|
|
103
88
|
/**
|
|
104
89
|
* 用于显示元素并获取它的高度宽度等其它属性
|
|
@@ -1078,7 +1063,7 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1078
1063
|
super(option);
|
|
1079
1064
|
}
|
|
1080
1065
|
/** 版本号 */
|
|
1081
|
-
version = "2025.
|
|
1066
|
+
version = "2025.4.8";
|
|
1082
1067
|
attr(element, attrName, attrValue) {
|
|
1083
1068
|
let DOMUtilsContext = this;
|
|
1084
1069
|
if (typeof element === "string") {
|
|
@@ -1221,6 +1206,19 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1221
1206
|
else ;
|
|
1222
1207
|
return;
|
|
1223
1208
|
}
|
|
1209
|
+
let setStyleProperty = (propertyName, propertyValue) => {
|
|
1210
|
+
if (propertyValue === "string" && propertyValue.includes("!important")) {
|
|
1211
|
+
propertyValue = propertyValue
|
|
1212
|
+
.trim()
|
|
1213
|
+
.replace(/!important$/gi, "")
|
|
1214
|
+
.trim();
|
|
1215
|
+
element.style.setProperty(propertyName, propertyValue, "important");
|
|
1216
|
+
}
|
|
1217
|
+
else {
|
|
1218
|
+
propertyValue = handlePixe(propertyName, propertyValue);
|
|
1219
|
+
element.style.setProperty(propertyName, propertyValue);
|
|
1220
|
+
}
|
|
1221
|
+
};
|
|
1224
1222
|
if (typeof property === "string") {
|
|
1225
1223
|
if (value == null) {
|
|
1226
1224
|
return DOMUtilsContext.windowApi.globalThis
|
|
@@ -1228,28 +1226,19 @@ System.register('DOMUtils', [], (function (exports) {
|
|
|
1228
1226
|
.getPropertyValue(property);
|
|
1229
1227
|
}
|
|
1230
1228
|
else {
|
|
1231
|
-
|
|
1232
|
-
element.style.setProperty(property, value, "important");
|
|
1233
|
-
}
|
|
1234
|
-
else {
|
|
1235
|
-
value = handlePixe(property, value);
|
|
1236
|
-
element.style.setProperty(property, value);
|
|
1237
|
-
}
|
|
1229
|
+
setStyleProperty(property, value);
|
|
1238
1230
|
}
|
|
1239
1231
|
}
|
|
1240
1232
|
else if (typeof property === "object") {
|
|
1241
1233
|
for (let prop in property) {
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
element.style.setProperty(prop, property[prop], "important");
|
|
1245
|
-
}
|
|
1246
|
-
else {
|
|
1247
|
-
property[prop] = handlePixe(prop, property[prop]);
|
|
1248
|
-
element.style.setProperty(prop, property[prop]);
|
|
1249
|
-
}
|
|
1234
|
+
let value = property[prop];
|
|
1235
|
+
setStyleProperty(prop, value);
|
|
1250
1236
|
}
|
|
1251
1237
|
}
|
|
1252
|
-
else
|
|
1238
|
+
else {
|
|
1239
|
+
// 其他情况
|
|
1240
|
+
throw new TypeError("property must be string or object");
|
|
1241
|
+
}
|
|
1253
1242
|
}
|
|
1254
1243
|
text(element, text) {
|
|
1255
1244
|
let DOMUtilsContext = this;
|