@dcloudio/uni-template-compiler 2.0.1-alpha-33820220118002 → 2.0.1-alpha-33920220222001
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/lib/constants.js
CHANGED
|
@@ -28,7 +28,6 @@ const INTERNAL_GET_EVENT = '__get_event'
|
|
|
28
28
|
const INTERNAL_GET_REFS = '__get_refs'
|
|
29
29
|
const INTERNAL_EVENT_PROXY = '__e'
|
|
30
30
|
const INTERNAL_EVENT_LINK = '__l'
|
|
31
|
-
const INTERNAL_EVENT_WRAP = '__w'
|
|
32
31
|
|
|
33
32
|
const ALLOWED_GLOBAL_OBJECT = [
|
|
34
33
|
'Math',
|
|
@@ -64,7 +63,6 @@ module.exports = {
|
|
|
64
63
|
ATTR_DATA_EVENT_OPTS: 'data-event-opts',
|
|
65
64
|
ATTR_DATA_COM_TYPE: 'data-com-type',
|
|
66
65
|
ATTR_DATA_EVENT_PARAMS: 'data-event-params',
|
|
67
|
-
ATTR_DATA_EVENT_LIST: 'data-event-list',
|
|
68
66
|
ATTE_DATA_CUSTOM_HIDDEN: 'data-custom-hidden',
|
|
69
67
|
INTERNAL_GET_ORIG,
|
|
70
68
|
INTERNAL_GET_CLASS,
|
|
@@ -73,7 +71,6 @@ module.exports = {
|
|
|
73
71
|
INTERNAL_GET_REFS,
|
|
74
72
|
INTERNAL_EVENT_PROXY,
|
|
75
73
|
INTERNAL_EVENT_LINK,
|
|
76
|
-
INTERNAL_EVENT_WRAP,
|
|
77
74
|
INTERNAL_SET_MODEL,
|
|
78
75
|
INTERNAL_SET_SYNC,
|
|
79
76
|
METHOD_BUILT_IN: [
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
const t = require('@babel/types')
|
|
2
2
|
|
|
3
3
|
const {
|
|
4
|
-
|
|
5
|
-
ATTR_DATA_EVENT_OPTS,
|
|
6
|
-
ATTR_DATA_COM_TYPE,
|
|
7
|
-
ATTR_DATA_EVENT_LIST,
|
|
8
|
-
ATTR_DATA_EVENT_PARAMS,
|
|
9
|
-
ATTE_DATA_CUSTOM_HIDDEN,
|
|
10
|
-
INTERNAL_EVENT_WRAP
|
|
4
|
+
ATTR_DATA_COM_TYPE
|
|
11
5
|
} = require('../../../constants')
|
|
12
6
|
|
|
13
7
|
const processRef = require('./ref')
|
|
@@ -43,8 +37,7 @@ module.exports = function traverseData (path, state, tagName) {
|
|
|
43
37
|
})
|
|
44
38
|
|
|
45
39
|
// 该组件是引入的小程序组件
|
|
46
|
-
|
|
47
|
-
if (wxComponent) {
|
|
40
|
+
if (state.options.wxComponents[tagName]) {
|
|
48
41
|
addAttrProperties.push(
|
|
49
42
|
t.objectProperty(
|
|
50
43
|
t.stringLiteral(ATTR_DATA_COM_TYPE),
|
|
@@ -58,81 +51,6 @@ module.exports = function traverseData (path, state, tagName) {
|
|
|
58
51
|
t.stringLiteral('__r')
|
|
59
52
|
)
|
|
60
53
|
)
|
|
61
|
-
const properties = path.node.properties.find(prop => prop.key.name === 'on').value.properties
|
|
62
|
-
const list = []
|
|
63
|
-
for (let index = 0; index < properties.length; index++) {
|
|
64
|
-
const element = properties[index]
|
|
65
|
-
if (element.value.value === '__e') {
|
|
66
|
-
list.push(element.key.value)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
addAttrProperties.push(
|
|
70
|
-
t.objectProperty(
|
|
71
|
-
t.stringLiteral(ATTR_DATA_EVENT_LIST),
|
|
72
|
-
t.stringLiteral(list.join(','))
|
|
73
|
-
)
|
|
74
|
-
)
|
|
75
|
-
if (wxComponent.startsWith('plugin://')) {
|
|
76
|
-
const wrapperTag = 'plugin-wrapper'
|
|
77
|
-
const orgPath = path.parentPath
|
|
78
|
-
const orgNode = orgPath.node
|
|
79
|
-
const args = orgNode.arguments
|
|
80
|
-
const orgTag = args[0]
|
|
81
|
-
orgTag.$mpPlugin = true
|
|
82
|
-
args[0] = t.stringLiteral(wrapperTag)
|
|
83
|
-
const orgOptions = args[1]
|
|
84
|
-
const orgOptionsProps = orgOptions.properties
|
|
85
|
-
const targetAttrs = []
|
|
86
|
-
const targetOptionsProps = [
|
|
87
|
-
t.objectProperty(t.identifier('attrs'), t.objectExpression(targetAttrs))
|
|
88
|
-
]
|
|
89
|
-
const uniAttrs = [
|
|
90
|
-
ATTR_DATA_EVENT_OPTS,
|
|
91
|
-
ATTR_DATA_COM_TYPE,
|
|
92
|
-
ATTR_DATA_EVENT_PARAMS,
|
|
93
|
-
ATTR_DATA_EVENT_LIST,
|
|
94
|
-
ATTE_DATA_CUSTOM_HIDDEN,
|
|
95
|
-
'vue-id'
|
|
96
|
-
]
|
|
97
|
-
for (let a = orgOptionsProps.length - 1; a >= 0; a--) {
|
|
98
|
-
const prop = orgOptionsProps[a]
|
|
99
|
-
if (prop.key.name === 'attrs') {
|
|
100
|
-
const attrs = prop.value.properties
|
|
101
|
-
for (let b = attrs.length - 1; b >= 0; b--) {
|
|
102
|
-
const element = attrs[b]
|
|
103
|
-
const key = element.key.value
|
|
104
|
-
if (!uniAttrs.includes(key)) {
|
|
105
|
-
attrs.splice(b, 1)
|
|
106
|
-
targetAttrs.push(element)
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
attrs.push(t.objectProperty(t.stringLiteral('onPluginWrap'), t.stringLiteral(INTERNAL_EVENT_WRAP)))
|
|
110
|
-
} else if (prop.key.name === 'on') {
|
|
111
|
-
const ons = prop.value.properties
|
|
112
|
-
ons.forEach(item => {
|
|
113
|
-
const attrs = path.node.properties.find(prop => prop.key.name === 'attrs').value.properties
|
|
114
|
-
const vueId = attrs.find(prop => prop.key.value === 'vue-id').value
|
|
115
|
-
const eventName = item.key.value
|
|
116
|
-
targetAttrs.push(t.objectProperty(t.stringLiteral(eventName), t.binaryExpression('+', t.stringLiteral(eventName), vueId)))
|
|
117
|
-
})
|
|
118
|
-
} else {
|
|
119
|
-
orgOptionsProps.splice(a, 1)
|
|
120
|
-
targetOptionsProps.push(prop)
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
const orgChild = args[2]
|
|
124
|
-
const targetOptions = t.objectExpression(targetOptionsProps)
|
|
125
|
-
targetOptions.$mpProcessed = true
|
|
126
|
-
const targetArguments = [
|
|
127
|
-
orgTag,
|
|
128
|
-
targetOptions
|
|
129
|
-
]
|
|
130
|
-
if (orgChild) {
|
|
131
|
-
targetArguments.push(orgChild)
|
|
132
|
-
}
|
|
133
|
-
const targetNode = t.callExpression(t.identifier(METHOD_CREATE_ELEMENT), targetArguments)
|
|
134
|
-
args[2] = targetNode
|
|
135
|
-
}
|
|
136
54
|
}
|
|
137
55
|
}
|
|
138
56
|
|
|
@@ -167,8 +167,7 @@ module.exports = {
|
|
|
167
167
|
tagNode.value = getComponentName(hyphenate(tagName))
|
|
168
168
|
|
|
169
169
|
// 组件增加 vueId
|
|
170
|
-
|
|
171
|
-
if (this.options.platform.isComponent(tagNode.value) && !tagNode.$mpPlugin) {
|
|
170
|
+
if (this.options.platform.isComponent(tagNode.value)) {
|
|
172
171
|
addVueId(path, this)
|
|
173
172
|
}
|
|
174
173
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-template-compiler",
|
|
3
|
-
"version": "2.0.1-alpha-
|
|
3
|
+
"version": "2.0.1-alpha-33920220222001",
|
|
4
4
|
"description": "uni-template-compiler",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"@babel/types": "^7.3.3",
|
|
23
23
|
"vue-template-compiler": "^2.6.10"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "9cdc7f8c69c2a63222d2eed59aa0b3aff4f75842"
|
|
26
26
|
}
|