Avoid unnecessary getUnescapedAttributeValue() call (#17947)
This commit is contained in:
1 parent
e1f0bdceb2
commit
6df61307be
2 files changed
+21
-11
No files matched your search
+7
-6
@@ -68,22 +68,23 @@ function printAngularAttribute(path, options) {
|
||||
return printNgDirective;
|
||||
}
|
||||
|
||||
const value = getUnescapedAttributeValue(node);
|
||||
|
||||
/**
|
||||
* i18n="longDescription"
|
||||
* i18n-attr="longDescription"
|
||||
*/
|
||||
if (/^i18n(?:-.+)?$/u.test(attributeName)) {
|
||||
return () =>
|
||||
printExpand(
|
||||
return () => {
|
||||
const value = getUnescapedAttributeValue(node);
|
||||
return printExpand(
|
||||
fill(getTextValueParts(node, value.trim())),
|
||||
!value.includes("@@"),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
if (angularInterpolationRegex.test(value)) {
|
||||
return (textToDoc) => printAngularInterpolation(value, textToDoc);
|
||||
if (angularInterpolationRegex.test(node.value)) {
|
||||
return (textToDoc) =>
|
||||
printAngularInterpolation(getUnescapedAttributeValue(node), textToDoc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,13 @@ function printVueAttribute(path, options) {
|
||||
return printVueScriptGenericAttributeValue;
|
||||
}
|
||||
|
||||
const value = getUnescapedAttributeValue(node);
|
||||
const parseWithTs = isVueSfcWithTypescriptScript(path, options);
|
||||
|
||||
if (isVueSlotAttribute(node) || isVueSfcBindingsAttribute(node, options)) {
|
||||
return (textToDoc) => printVueBindings(value, textToDoc, { parseWithTs });
|
||||
return (textToDoc) =>
|
||||
printVueBindings(getUnescapedAttributeValue(node), textToDoc, {
|
||||
parseWithTs,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +47,9 @@ function printVueAttribute(path, options) {
|
||||
*/
|
||||
if (attributeName.startsWith("@") || attributeName.startsWith("v-on:")) {
|
||||
return (textToDoc) =>
|
||||
printVueVOnDirective(value, textToDoc, { parseWithTs });
|
||||
printVueVOnDirective(getUnescapedAttributeValue(node), textToDoc, {
|
||||
parseWithTs,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,14 +63,19 @@ function printVueAttribute(path, options) {
|
||||
attributeName.startsWith("v-bind:")
|
||||
) {
|
||||
return (textToDoc) =>
|
||||
printVueVBindDirective(value, textToDoc, { parseWithTs });
|
||||
printVueVBindDirective(getUnescapedAttributeValue(node), textToDoc, {
|
||||
parseWithTs,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* v-if="jsExpression"
|
||||
*/
|
||||
if (attributeName.startsWith("v-")) {
|
||||
return (textToDoc) => printExpression(value, textToDoc, { parseWithTs });
|
||||
return (textToDoc) =>
|
||||
printExpression(getUnescapedAttributeValue(node), textToDoc, {
|
||||
parseWithTs,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user