@sprlab/wccompiler 0.8.3 → 0.8.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/integrations/vue.js +15 -6
- package/package.json +1 -1
package/integrations/vue.js
CHANGED
|
@@ -60,13 +60,13 @@ function wccVModelTransform(node, context) {
|
|
|
60
60
|
let modified = false;
|
|
61
61
|
|
|
62
62
|
for (const prop of node.props) {
|
|
63
|
-
// Check if this is a v-model directive with
|
|
63
|
+
// Check if this is a v-model directive (with or without argument)
|
|
64
64
|
if (
|
|
65
65
|
prop.type === 7 && // DIRECTIVE
|
|
66
|
-
prop.name === 'model'
|
|
67
|
-
prop.arg // has argument (v-model:name)
|
|
66
|
+
prop.name === 'model'
|
|
68
67
|
) {
|
|
69
|
-
|
|
68
|
+
// Determine prop name: explicit arg or default 'modelValue'
|
|
69
|
+
const propName = prop.arg ? prop.arg.content : 'modelValue';
|
|
70
70
|
const expr = prop.exp;
|
|
71
71
|
|
|
72
72
|
if (!expr) {
|
|
@@ -74,12 +74,21 @@ function wccVModelTransform(node, context) {
|
|
|
74
74
|
continue;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
// Create the arg node (use existing or create for modelValue)
|
|
78
|
+
const argNode = prop.arg || {
|
|
79
|
+
type: 4, // SIMPLE_EXPRESSION
|
|
80
|
+
content: 'modelValue',
|
|
81
|
+
isStatic: true,
|
|
82
|
+
constType: 3,
|
|
83
|
+
loc: prop.loc
|
|
84
|
+
};
|
|
85
|
+
|
|
77
86
|
// Replace v-model:propName="expr" with:
|
|
78
87
|
// :propName="expr" (bind directive)
|
|
79
88
|
newProps.push({
|
|
80
89
|
type: 7, // DIRECTIVE
|
|
81
90
|
name: 'bind',
|
|
82
|
-
arg:
|
|
91
|
+
arg: argNode,
|
|
83
92
|
exp: expr,
|
|
84
93
|
modifiers: [],
|
|
85
94
|
loc: prop.loc
|
|
@@ -98,7 +107,7 @@ function wccVModelTransform(node, context) {
|
|
|
98
107
|
},
|
|
99
108
|
exp: {
|
|
100
109
|
type: 4, // SIMPLE_EXPRESSION
|
|
101
|
-
content: `$event => { ${expr.content} = $event }`,
|
|
110
|
+
content: `$event => { ${expr.content} = $event.detail ?? $event }`,
|
|
102
111
|
isStatic: false,
|
|
103
112
|
constType: 0,
|
|
104
113
|
loc: prop.loc
|
package/package.json
CHANGED