@plumeria/compiler 0.14.7 → 0.14.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.
- package/dist/extract.js +19 -1
- package/package.json +1 -1
package/dist/extract.js
CHANGED
|
@@ -29,6 +29,21 @@ function isInComment(code, position) {
|
|
|
29
29
|
}
|
|
30
30
|
return inMultiLineComment;
|
|
31
31
|
}
|
|
32
|
+
function isInVueAttribute(code, position) {
|
|
33
|
+
let quotePosition = -1;
|
|
34
|
+
for (let i = position - 1; i >= 0; i--) {
|
|
35
|
+
const char = code[i];
|
|
36
|
+
if (char === '"' || char === "'") {
|
|
37
|
+
quotePosition = i;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (quotePosition === -1)
|
|
42
|
+
return false;
|
|
43
|
+
const beforeQuote = code.substring(Math.max(0, quotePosition - 30), quotePosition);
|
|
44
|
+
const vueAttributePattern = /(:|v-bind:)(class|style)\s*=\s*$/;
|
|
45
|
+
return vueAttributePattern.test(beforeQuote);
|
|
46
|
+
}
|
|
32
47
|
function isInString(code, position) {
|
|
33
48
|
let inSingleQuote = false;
|
|
34
49
|
let inDoubleQuote = false;
|
|
@@ -67,7 +82,10 @@ function isInString(code, position) {
|
|
|
67
82
|
}
|
|
68
83
|
}
|
|
69
84
|
}
|
|
70
|
-
|
|
85
|
+
const inStringLiteral = inSingleQuote || inDoubleQuote || inBacktick;
|
|
86
|
+
if (inStringLiteral && isInVueAttribute(code, position))
|
|
87
|
+
return false;
|
|
88
|
+
return inStringLiteral;
|
|
71
89
|
}
|
|
72
90
|
function isInHtmlText(code, position) {
|
|
73
91
|
let lastOpenTag = -1;
|