Fix HTML attribute value in AST massage (#17944)
This commit is contained in:
1 parent
c885875926
commit
e1f0bdceb2
1 file changed
+32
-1
@@ -39,7 +39,38 @@ function clean(original, cloned) {
|
||||
}
|
||||
|
||||
if (original.type === "attribute") {
|
||||
delete cloned.value;
|
||||
const { fullName: name, value } = original;
|
||||
|
||||
if (
|
||||
// HTML attributes
|
||||
name === "style" ||
|
||||
name === "class" ||
|
||||
name === "srcset" ||
|
||||
name.startsWith("on") ||
|
||||
// Vue attributes
|
||||
name.startsWith("@") ||
|
||||
name.startsWith(":") ||
|
||||
name.startsWith(".") ||
|
||||
name.startsWith("#") ||
|
||||
name.startsWith("v-") ||
|
||||
name === "vars" ||
|
||||
name === "setup" ||
|
||||
name === "generic" ||
|
||||
name === "slot-scope" ||
|
||||
// Angular attributes
|
||||
name.startsWith("(") ||
|
||||
name.startsWith("[") ||
|
||||
name.startsWith("*") ||
|
||||
name.startsWith("bind") ||
|
||||
name.startsWith("i18n") ||
|
||||
name.startsWith("on-") ||
|
||||
name.startsWith("ng-") ||
|
||||
value?.includes("{{")
|
||||
) {
|
||||
delete cloned.value;
|
||||
} else if (value) {
|
||||
cloned.value = value.replaceAll(/'|"|'/gu, '"');
|
||||
}
|
||||
}
|
||||
|
||||
if (original.type === "docType") {
|
||||
|
||||
Reference in new issue
Block a user