@vue-macros/volar
Advanced tools
Comparing version 0.18.11 to 0.18.12
@@ -123,3 +123,3 @@ // src/jsx-directive.ts | ||
const node2 = ts.isJsxElement(child) && child.openingElement.tagName.getText(sfc[source]?.ast) === "template" ? child.children : child; | ||
return ts.isJsxSelfClosingElement(child) ? "" : [ | ||
return [ | ||
sfc[source].content.slice(node2.pos, node2.end), | ||
@@ -318,9 +318,15 @@ source, | ||
const result = []; | ||
for (const { attribute: attribute2, node: node2 } of nodes) { | ||
for (const { attribute: attribute2, node } of nodes) { | ||
const tagName2 = ts.isJsxSelfClosingElement(node) ? node.tagName.getText(sfc[source]?.ast) : ts.isJsxElement(node) ? node.openingElement.tagName.getText(sfc[source]?.ast) : ""; | ||
const modelValue = ["input", "select", "textarea"].includes(tagName2) ? "value" : "modelValue"; | ||
const isArrayExpression = attribute2.initializer && ts.isJsxExpression(attribute2.initializer) && attribute2.initializer.expression && ts.isArrayLiteralExpression(attribute2.initializer.expression); | ||
if (attribute2.name.getText(sfc[source]?.ast).startsWith("v-model:") || isArrayExpression) { | ||
let isDynamic = false; | ||
const attributeName = (0, import_shared.camelize)( | ||
attribute2.name.getText(sfc[source]?.ast).slice(8).split(" ")[0].split("_")[0] | ||
attribute2.name.getText(sfc[source]?.ast).slice(8).split(" ")[0].split("_")[0].replace(/^\$(.*)\$/, (_, $1) => { | ||
isDynamic = true; | ||
return $1; | ||
}) | ||
); | ||
firstNamespacedNode ??= { attribute: attribute2, node: node2 }; | ||
firstNamespacedNode ??= { attribute: attribute2, tagName: tagName2 }; | ||
if (firstNamespacedNode.attribute !== attribute2) { | ||
@@ -338,18 +344,19 @@ (0, import_language_core5.replaceSourceRange)( | ||
if (elements[1] && !ts.isArrayLiteralExpression(elements[1])) { | ||
if (!ts.isStringLiteral(elements[1])) | ||
result.push("[`${"); | ||
result.push([ | ||
elements[1].getText(sfc[source]?.ast), | ||
source, | ||
elements[1].getStart(sfc[source]?.ast), | ||
import_language_core5.FileRangeCapabilities.full | ||
]); | ||
if (!ts.isStringLiteral(elements[1])) | ||
result.push("}`]"); | ||
isDynamic = !ts.isStringLiteral(elements[1]); | ||
result.push( | ||
isDynamic ? "[`${" : "", | ||
[ | ||
elements[1].getText(sfc[source]?.ast), | ||
source, | ||
elements[1].getStart(sfc[source]?.ast), | ||
import_language_core5.FileRangeCapabilities.full | ||
], | ||
isDynamic ? "}`]" : "" | ||
); | ||
} else { | ||
result.push("modelValue"); | ||
result.push(modelValue); | ||
} | ||
if (elements[0]) | ||
result.push([ | ||
`:${elements[0].getText(sfc[source]?.ast)}`, | ||
result.push(":", [ | ||
elements[0].getText(sfc[source]?.ast), | ||
source, | ||
@@ -360,13 +367,20 @@ elements[0].getStart(sfc[source]?.ast), | ||
} else { | ||
result.push([ | ||
attributeName, | ||
source, | ||
[attribute2.name.getStart(sfc[source]?.ast) + 8, attribute2.name.end], | ||
import_language_core5.FileRangeCapabilities.full | ||
]); | ||
result.push( | ||
isDynamic ? "[`${" : "", | ||
[ | ||
attributeName, | ||
source, | ||
[ | ||
attribute2.name.getStart(sfc[source]?.ast) + 8, | ||
attribute2.name.getEnd() | ||
], | ||
import_language_core5.FileRangeCapabilities.full | ||
], | ||
isDynamic ? "}`]" : "" | ||
); | ||
if (attribute2.initializer && attributeName) | ||
result.push([ | ||
`:${attribute2.initializer.getText(sfc[source]?.ast).slice(1, -1)}`, | ||
result.push(":", [ | ||
attribute2.initializer.getText(sfc[source]?.ast).slice(1, -1), | ||
source, | ||
attribute2.initializer.getStart(sfc[source]?.ast), | ||
attribute2.initializer.getStart(sfc[source]?.ast) + 1, | ||
import_language_core5.FileRangeCapabilities.full | ||
@@ -381,5 +395,4 @@ ]); | ||
attribute2.name.getEnd() + 1, | ||
`onUpdate:modelValue={() => {}} `, | ||
[ | ||
"modelValue", | ||
modelValue, | ||
source, | ||
@@ -395,5 +408,4 @@ [attribute2.name.getStart(sfc[source]?.ast), attribute2.name.getEnd()], | ||
return; | ||
const { node, attribute } = firstNamespacedNode; | ||
const { attribute, tagName } = firstNamespacedNode; | ||
getModelsType(codes); | ||
const tagName = ts.isJsxSelfClosingElement(node) ? node.tagName.getText(sfc[source]?.ast) : ts.isJsxElement(node) ? node.openingElement.tagName.getText(sfc[source]?.ast) : null; | ||
(0, import_language_core5.replaceSourceRange)( | ||
@@ -400,0 +412,0 @@ codes, |
{ | ||
"name": "@vue-macros/volar", | ||
"version": "0.18.11", | ||
"packageManager": "pnpm@8.14.1", | ||
"version": "0.18.12", | ||
"packageManager": "pnpm@8.15.5", | ||
"description": "Volar plugin for Vue Macros.", | ||
@@ -49,3 +49,3 @@ "keywords": [ | ||
"@vue/language-core": "1.8.27", | ||
"@vue/shared": "^3.4.13", | ||
"@vue/shared": "^3.4.21", | ||
"@vue-macros/common": "1.10.1", | ||
@@ -57,4 +57,4 @@ "@vue-macros/define-props": "2.0.3", | ||
"devDependencies": { | ||
"@vue/compiler-dom": "^3.4.13", | ||
"typescript": "~5.3.3", | ||
"@vue/compiler-dom": "^3.4.21", | ||
"typescript": "~5.4.2", | ||
"vue-tsc": "1.8.27" | ||
@@ -61,0 +61,0 @@ }, |
42128
1274
Updated@vue/shared@^3.4.21