@slim-lang/core 1.2.11 → 1.2.12
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/package.json
CHANGED
|
@@ -22,8 +22,6 @@ function kebabCase(name) {
|
|
|
22
22
|
.toLowerCase()
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
// The expression that turns the template into a DOM element, resolving `&`
|
|
26
|
-
// parent references first when BEM classes are enabled.
|
|
27
25
|
function elementExpr(html, name) {
|
|
28
26
|
if (!useBEMClasses()) return `htmlToVdom(__html__\`${html}\`).toElement()`
|
|
29
27
|
return `(() => { const __v__ = htmlToVdom(__html__\`${html}\`); __resolve_bem__(__v__, ${JSON.stringify(kebabCase(name))}); return __v__.toElement(); })()`
|
|
@@ -45,8 +43,26 @@ function templateReturnStart(body) {
|
|
|
45
43
|
return -1
|
|
46
44
|
}
|
|
47
45
|
|
|
46
|
+
function literalRanges(code) {
|
|
47
|
+
const tokens = tokenize(code);
|
|
48
|
+
const literal = t => t.type === "string" || t.type === "template" || t.type === "comment" || t.type === "regex";
|
|
49
|
+
|
|
50
|
+
return offset => {
|
|
51
|
+
let lo = 0, hi = tokens.length - 1;
|
|
52
|
+
while (lo <= hi) {
|
|
53
|
+
const mid = (lo + hi) >> 1;
|
|
54
|
+
const t = tokens[mid];
|
|
55
|
+
if (offset < t.start) hi = mid - 1;
|
|
56
|
+
else if (offset >= t.end) lo = mid + 1;
|
|
57
|
+
else return literal(t);
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
48
63
|
function parseComponentsEdits(code) {
|
|
49
64
|
const edits = [];
|
|
65
|
+
const inLiteral = literalRanges(code);
|
|
50
66
|
let i = 0;
|
|
51
67
|
|
|
52
68
|
while (i < code.length) {
|
|
@@ -60,6 +76,11 @@ function parseComponentsEdits(code) {
|
|
|
60
76
|
const tag = match[2] ?? null;
|
|
61
77
|
const start = i + match.index;
|
|
62
78
|
|
|
79
|
+
if (inLiteral(start + match[0].length - "component".length)) {
|
|
80
|
+
i = start + match[0].length;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
|
|
63
84
|
let p = start + match[0].length;
|
|
64
85
|
|
|
65
86
|
while (/\s/.test(code[p])) p++;
|