@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.
Files changed (2) hide show
  1. package/index.js +13 -11
  2. 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 (Array.isArray(html)) {
138
- for (let i = 0; i < html.length; i++) {
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[i].classList.add(element.classList);
148
+ html.classList.add(element.classList);
141
149
  if (element.style.cssText) {
142
- html[i].style.cssText += element.style.cssText;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joyzl/eno",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Easy Node Object",
5
5
  "main": "dist/joyzl-eno.js",
6
6
  "module": "index.js",