@vue/language-core 2.2.6 → 2.2.8
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.
|
@@ -6,5 +6,4 @@ import type { TemplateCodegenOptions } from './index';
|
|
|
6
6
|
export declare function generateElementEvents(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, node: CompilerDOM.ElementNode, componentFunctionalVar: string, componentVNodeVar: string, componentCtxVar: string): Generator<Code>;
|
|
7
7
|
export declare function generateEventArg(ctx: TemplateCodegenContext, name: string, start: number, directive?: string): Generator<Code>;
|
|
8
8
|
export declare function generateEventExpression(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode): Generator<Code>;
|
|
9
|
-
export declare function generateModelEventExpression(options: TemplateCodegenOptions, ctx: TemplateCodegenContext, prop: CompilerDOM.DirectiveNode): Generator<Code>;
|
|
10
9
|
export declare function isCompoundExpression(ts: typeof import('typescript'), ast: ts.SourceFile): boolean;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.generateElementEvents = generateElementEvents;
|
|
4
4
|
exports.generateEventArg = generateEventArg;
|
|
5
5
|
exports.generateEventExpression = generateEventExpression;
|
|
6
|
-
exports.generateModelEventExpression = generateModelEventExpression;
|
|
7
6
|
exports.isCompoundExpression = isCompoundExpression;
|
|
8
7
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
9
8
|
const shared_1 = require("@vue/shared");
|
|
@@ -17,8 +16,9 @@ function* generateElementEvents(options, ctx, node, componentFunctionalVar, comp
|
|
|
17
16
|
let propsVar;
|
|
18
17
|
for (const prop of node.props) {
|
|
19
18
|
if (prop.type === CompilerDOM.NodeTypes.DIRECTIVE
|
|
20
|
-
&&
|
|
21
|
-
|
|
19
|
+
&& prop.name === 'on'
|
|
20
|
+
&& prop.arg?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION
|
|
21
|
+
&& prop.arg.isStatic) {
|
|
22
22
|
ctx.currentComponent.used = true;
|
|
23
23
|
if (!emitVar) {
|
|
24
24
|
emitVar = ctx.getInternalVariable();
|
|
@@ -28,31 +28,21 @@ function* generateElementEvents(options, ctx, node, componentFunctionalVar, comp
|
|
|
28
28
|
yield `let ${eventsVar}!: __VLS_NormalizeEmits<typeof ${emitVar}>${utils_1.endOfLine}`;
|
|
29
29
|
yield `let ${propsVar}!: __VLS_FunctionalComponentProps<typeof ${componentFunctionalVar}, typeof ${componentVNodeVar}>${utils_1.endOfLine}`;
|
|
30
30
|
}
|
|
31
|
-
let source = prop.arg
|
|
32
|
-
let start = prop.arg
|
|
33
|
-
let propPrefix = 'on
|
|
31
|
+
let source = prop.arg.loc.source;
|
|
32
|
+
let start = prop.arg.loc.start.offset;
|
|
33
|
+
let propPrefix = 'on';
|
|
34
34
|
let emitPrefix = '';
|
|
35
|
-
if (
|
|
36
|
-
propPrefix = 'onUpdate:';
|
|
37
|
-
emitPrefix = 'update:';
|
|
38
|
-
}
|
|
39
|
-
else if (source.startsWith('vue:')) {
|
|
35
|
+
if (source.startsWith('vue:')) {
|
|
40
36
|
source = source.slice('vue:'.length);
|
|
41
37
|
start = start + 'vue:'.length;
|
|
42
|
-
propPrefix = 'onVnode
|
|
38
|
+
propPrefix = 'onVnode';
|
|
43
39
|
emitPrefix = 'vnode-';
|
|
44
40
|
}
|
|
45
|
-
yield `(): __VLS_NormalizeComponentEvent<typeof ${propsVar}, typeof ${eventsVar}, '${(0, shared_1.camelize)(propPrefix + source)}', '${emitPrefix
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
yield `'${(0, shared_1.camelize)(propPrefix + source)}': `;
|
|
53
|
-
yield* generateModelEventExpression(options, ctx, prop);
|
|
54
|
-
}
|
|
55
|
-
yield `})${utils_1.endOfLine}`;
|
|
41
|
+
yield `const ${ctx.getInternalVariable()}: __VLS_NormalizeComponentEvent<typeof ${propsVar}, typeof ${eventsVar}, '${(0, shared_1.camelize)(propPrefix + '-' + source)}', '${emitPrefix}${source}', '${(0, shared_1.camelize)(emitPrefix + source)}'> = {${utils_1.newLine}`;
|
|
42
|
+
yield* generateEventArg(ctx, source, start, propPrefix);
|
|
43
|
+
yield `: `;
|
|
44
|
+
yield* generateEventExpression(options, ctx, prop);
|
|
45
|
+
yield `}${utils_1.endOfLine}`;
|
|
56
46
|
}
|
|
57
47
|
}
|
|
58
48
|
}
|
|
@@ -115,16 +105,6 @@ function* generateEventExpression(options, ctx, prop) {
|
|
|
115
105
|
yield `() => {}`;
|
|
116
106
|
}
|
|
117
107
|
}
|
|
118
|
-
function* generateModelEventExpression(options, ctx, prop) {
|
|
119
|
-
if (prop.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
120
|
-
yield `(...[$event]) => (`;
|
|
121
|
-
yield* (0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.verification, prop.exp.content, prop.exp.loc.start.offset, prop.exp.loc);
|
|
122
|
-
yield ` = $event)`;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
yield `() => {}`;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
108
|
function isCompoundExpression(ts, ast) {
|
|
129
109
|
let result = true;
|
|
130
110
|
if (ast.statements.length === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"optional": true
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "cdf00e6f19971260607ea2347924b94126a254fc"
|
|
41
41
|
}
|