@mpxjs/webpack-plugin 2.9.15 → 2.9.16

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.
@@ -201,19 +201,30 @@ module.exports = function getSpec ({ warn, error }) {
201
201
  {
202
202
  // 样式类名绑定
203
203
  test: /^(class|wx:class)$/,
204
- web ({ value }, { el }) {
205
- if (el.isClassParsed) {
206
- return false
207
- }
204
+ web ({ name, value }, { el }) {
205
+ if (el.classMerged) return false
208
206
  const classBinding = []
209
- el.isClassParsed = true
210
- el.attrsList.filter(item => this.test.test(item.name)).forEach((item) => {
211
- const parsed = parseMustacheWithContext(item.value)
212
- classBinding.push(parsed.result)
207
+ el.attrsList.filter(item => this.test.test(item.name)).forEach(({ name, value }) => {
208
+ const parsed = parseMustacheWithContext(value)
209
+ if (name === 'wx:class') {
210
+ classBinding.push(parsed.result)
211
+ } else if (name === 'class' && parsed.hasBinding === true) {
212
+ el.classMerged = true
213
+ classBinding.push(parsed.result)
214
+ }
213
215
  })
214
- return {
215
- name: ':class',
216
- value: `[${classBinding}]`
216
+
217
+ if (el.classMerged) {
218
+ return {
219
+ name: ':class',
220
+ value: `[${classBinding}]`
221
+ }
222
+ } else if (name === 'wx:class') {
223
+ // 对于纯静态class不做合并转换
224
+ return {
225
+ name: ':class',
226
+ value: classBinding[0]
227
+ }
217
228
  }
218
229
  }
219
230
  },
@@ -50,6 +50,11 @@
50
50
  url: this.url
51
51
  })
52
52
  break
53
+ case 'switchTab':
54
+ mpx.switchTab && mpx.switchTab({
55
+ url: this.url
56
+ })
57
+ break
53
58
  }
54
59
  }
55
60
  })
@@ -1715,7 +1715,7 @@ function processWebExternalClassesHack (el, options) {
1715
1715
 
1716
1716
  addAttrs(el, [{
1717
1717
  name: ':class',
1718
- value: `[${replacements.join(',')}]`
1718
+ value: `[${replacements}]`
1719
1719
  }])
1720
1720
  }
1721
1721
  }
@@ -1742,7 +1742,7 @@ function processWebExternalClassesHack (el, options) {
1742
1742
 
1743
1743
  addAttrs(el, [{
1744
1744
  name: ':' + classLikeAttrName,
1745
- value: `[${replacements.join(',')}].join(' ')`
1745
+ value: `[${replacements}].join(' ')`
1746
1746
  }])
1747
1747
  }
1748
1748
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.9.15",
3
+ "version": "2.9.16",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -83,5 +83,5 @@
83
83
  "engines": {
84
84
  "node": ">=14.14.0"
85
85
  },
86
- "gitHead": "f3dcf3425dc3e0ad2378b2f35ca020aa9cdd1fb2"
86
+ "gitHead": "60cfd1708a61c925d5fc08cca0b31a06b2c4c160"
87
87
  }