@joyzl/eno 1.2.3 → 1.2.4
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/index.js +13 -11
- package/package.json +1 -1
package/index.js
CHANGED
@@ -133,21 +133,23 @@ function replace(element, selector, html) {
|
|
133
133
|
}
|
134
134
|
|
135
135
|
if (element && html) {
|
136
|
-
//
|
137
|
-
if (
|
138
|
-
|
136
|
+
// 转移样式属性,如果有
|
137
|
+
if (element.classList && element.classList.length) {
|
138
|
+
if (Array.isArray(html)) {
|
139
|
+
for (let i = 0; i < html.length; i++) {
|
140
|
+
// TODO 需要测试验证
|
141
|
+
html[i].classList.add(element.classList);
|
142
|
+
if (element.style.cssText) {
|
143
|
+
html[i].style.cssText += element.style.cssText;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
} else {
|
139
147
|
// TODO 需要测试验证
|
140
|
-
html
|
148
|
+
html.classList.add(element.classList);
|
141
149
|
if (element.style.cssText) {
|
142
|
-
html
|
150
|
+
html.style.cssText += element.style.cssText;
|
143
151
|
}
|
144
152
|
}
|
145
|
-
} else {
|
146
|
-
// TODO 需要测试验证
|
147
|
-
html.classList.add(element.classList);
|
148
|
-
if (element.style.cssText) {
|
149
|
-
html.style.cssText += element.style.cssText;
|
150
|
-
}
|
151
153
|
}
|
152
154
|
element.replaceWith(TEMPLATE.content);
|
153
155
|
return html;
|