@marko/language-tools 2.5.20 → 2.5.21
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/index.js +15 -9
- package/dist/index.mjs +15 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -295,7 +295,7 @@ var Builder = class {
|
|
|
295
295
|
this.#openTagStart = void 0;
|
|
296
296
|
}
|
|
297
297
|
if (!range.expressions.length) {
|
|
298
|
-
switch (nameText = this.#code.slice(range.start, range.end)) {
|
|
298
|
+
switch (nameText = this.#code.slice(range.start, range.end) || "div") {
|
|
299
299
|
// All statement types will early return.
|
|
300
300
|
case "style": {
|
|
301
301
|
styleBlockReg.lastIndex = range.end;
|
|
@@ -930,6 +930,9 @@ var HTMLExtractor = class {
|
|
|
930
930
|
});
|
|
931
931
|
break;
|
|
932
932
|
case 1 /* Tag */: {
|
|
933
|
+
if (node.nameText === "script" || node.nameText === "style") {
|
|
934
|
+
break;
|
|
935
|
+
}
|
|
933
936
|
const nodeId = `${this.#nodeIdCounter++}`;
|
|
934
937
|
({ isDynamic, hasDynamicAttrs, hasDynamicBody } = this.#writeTag(
|
|
935
938
|
node,
|
|
@@ -954,10 +957,10 @@ var HTMLExtractor = class {
|
|
|
954
957
|
#writeTag(node, id) {
|
|
955
958
|
const isDynamic = !node.nameText || !isHTMLTag(node.nameText);
|
|
956
959
|
let hasDynamicAttrs = false, hasDynamicBody = false;
|
|
957
|
-
if (
|
|
958
|
-
({ hasDynamicAttrs, hasDynamicBody } = this.#writeHTMLTag(node, id));
|
|
959
|
-
} else {
|
|
960
|
+
if (isDynamic) {
|
|
960
961
|
this.#writeCustomTag(node);
|
|
962
|
+
} else {
|
|
963
|
+
({ hasDynamicAttrs, hasDynamicBody } = this.#writeHTMLTag(node, id));
|
|
961
964
|
}
|
|
962
965
|
return { isDynamic, hasDynamicAttrs, hasDynamicBody };
|
|
963
966
|
}
|
|
@@ -965,7 +968,7 @@ var HTMLExtractor = class {
|
|
|
965
968
|
var _a, _b;
|
|
966
969
|
let hasDynamicAttrs = false, hasDynamicBody = false;
|
|
967
970
|
this.#extractor.write("<");
|
|
968
|
-
this.#extractor.copy(node.name);
|
|
971
|
+
this.#extractor.copy(isEmptyRange(node.name) ? node.nameText : node.name);
|
|
969
972
|
this.#extractor.write(` data-marko-node-id="${id}"`);
|
|
970
973
|
(_a = node.attrs) == null ? void 0 : _a.forEach((attr) => {
|
|
971
974
|
if (attr.type === 10 /* AttrNamed */) this.#writeAttrNamed(attr);
|
|
@@ -1050,6 +1053,9 @@ function isVoidTag(tagName) {
|
|
|
1050
1053
|
return false;
|
|
1051
1054
|
}
|
|
1052
1055
|
}
|
|
1056
|
+
function isEmptyRange(range) {
|
|
1057
|
+
return range.start === range.end;
|
|
1058
|
+
}
|
|
1053
1059
|
|
|
1054
1060
|
// src/extractors/script/index.ts
|
|
1055
1061
|
var import_relative_import_path = require("relative-import-path");
|
|
@@ -2484,7 +2490,7 @@ constructor(_?: Return) {}
|
|
|
2484
2490
|
this.#extractor.write(`const ${varLocal("rendered_" + renderId)} = `);
|
|
2485
2491
|
}
|
|
2486
2492
|
if (isHTML) {
|
|
2487
|
-
this.#extractor.write(`${varShared("renderNativeTag")}("`).copy(tag.name).write('")');
|
|
2493
|
+
this.#extractor.write(`${varShared("renderNativeTag")}("`).copy(isEmptyRange2(tag.name) ? tagName : tag.name).write('")');
|
|
2488
2494
|
} else if (tagIdentifier) {
|
|
2489
2495
|
this.#extractor.write(
|
|
2490
2496
|
`${varShared(isTemplate ? "renderTemplate" : "renderDynamicTag")}(${tagIdentifier})`
|
|
@@ -2572,7 +2578,7 @@ constructor(_?: Return) {}
|
|
|
2572
2578
|
)`);
|
|
2573
2579
|
break;
|
|
2574
2580
|
case 10 /* AttrNamed */: {
|
|
2575
|
-
const isDefault =
|
|
2581
|
+
const isDefault = isEmptyRange2(attr.name);
|
|
2576
2582
|
const value = attr.value;
|
|
2577
2583
|
const modifierIndex = !isDefault && (!value || value.type === 13 /* AttrValue */) && this.#getNamedAttrModifierIndex(attr);
|
|
2578
2584
|
const defaultMapPosition = isDefault ? attr.name : void 0;
|
|
@@ -3184,7 +3190,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
3184
3190
|
}
|
|
3185
3191
|
}
|
|
3186
3192
|
#getDynamicTagExpression(tag) {
|
|
3187
|
-
if (tag.name.expressions.length === 1 &&
|
|
3193
|
+
if (tag.name.expressions.length === 1 && isEmptyRange2(tag.name.quasis[0]) && isEmptyRange2(tag.name.quasis[1])) {
|
|
3188
3194
|
return tag.name.expressions[0].value;
|
|
3189
3195
|
}
|
|
3190
3196
|
}
|
|
@@ -3351,7 +3357,7 @@ function stripExt(filename) {
|
|
|
3351
3357
|
function removeNewLines(str) {
|
|
3352
3358
|
return str.replace(REG_NEW_LINE, " ");
|
|
3353
3359
|
}
|
|
3354
|
-
function
|
|
3360
|
+
function isEmptyRange2(range) {
|
|
3355
3361
|
return range.start === range.end;
|
|
3356
3362
|
}
|
|
3357
3363
|
|
package/dist/index.mjs
CHANGED
|
@@ -255,7 +255,7 @@ var Builder = class {
|
|
|
255
255
|
this.#openTagStart = void 0;
|
|
256
256
|
}
|
|
257
257
|
if (!range.expressions.length) {
|
|
258
|
-
switch (nameText = this.#code.slice(range.start, range.end)) {
|
|
258
|
+
switch (nameText = this.#code.slice(range.start, range.end) || "div") {
|
|
259
259
|
// All statement types will early return.
|
|
260
260
|
case "style": {
|
|
261
261
|
styleBlockReg.lastIndex = range.end;
|
|
@@ -890,6 +890,9 @@ var HTMLExtractor = class {
|
|
|
890
890
|
});
|
|
891
891
|
break;
|
|
892
892
|
case 1 /* Tag */: {
|
|
893
|
+
if (node.nameText === "script" || node.nameText === "style") {
|
|
894
|
+
break;
|
|
895
|
+
}
|
|
893
896
|
const nodeId = `${this.#nodeIdCounter++}`;
|
|
894
897
|
({ isDynamic, hasDynamicAttrs, hasDynamicBody } = this.#writeTag(
|
|
895
898
|
node,
|
|
@@ -914,10 +917,10 @@ var HTMLExtractor = class {
|
|
|
914
917
|
#writeTag(node, id) {
|
|
915
918
|
const isDynamic = !node.nameText || !isHTMLTag(node.nameText);
|
|
916
919
|
let hasDynamicAttrs = false, hasDynamicBody = false;
|
|
917
|
-
if (
|
|
918
|
-
({ hasDynamicAttrs, hasDynamicBody } = this.#writeHTMLTag(node, id));
|
|
919
|
-
} else {
|
|
920
|
+
if (isDynamic) {
|
|
920
921
|
this.#writeCustomTag(node);
|
|
922
|
+
} else {
|
|
923
|
+
({ hasDynamicAttrs, hasDynamicBody } = this.#writeHTMLTag(node, id));
|
|
921
924
|
}
|
|
922
925
|
return { isDynamic, hasDynamicAttrs, hasDynamicBody };
|
|
923
926
|
}
|
|
@@ -925,7 +928,7 @@ var HTMLExtractor = class {
|
|
|
925
928
|
var _a, _b;
|
|
926
929
|
let hasDynamicAttrs = false, hasDynamicBody = false;
|
|
927
930
|
this.#extractor.write("<");
|
|
928
|
-
this.#extractor.copy(node.name);
|
|
931
|
+
this.#extractor.copy(isEmptyRange(node.name) ? node.nameText : node.name);
|
|
929
932
|
this.#extractor.write(` data-marko-node-id="${id}"`);
|
|
930
933
|
(_a = node.attrs) == null ? void 0 : _a.forEach((attr) => {
|
|
931
934
|
if (attr.type === 10 /* AttrNamed */) this.#writeAttrNamed(attr);
|
|
@@ -1010,6 +1013,9 @@ function isVoidTag(tagName) {
|
|
|
1010
1013
|
return false;
|
|
1011
1014
|
}
|
|
1012
1015
|
}
|
|
1016
|
+
function isEmptyRange(range) {
|
|
1017
|
+
return range.start === range.end;
|
|
1018
|
+
}
|
|
1013
1019
|
|
|
1014
1020
|
// src/extractors/script/index.ts
|
|
1015
1021
|
import { relativeImportPath } from "relative-import-path";
|
|
@@ -2447,7 +2453,7 @@ constructor(_?: Return) {}
|
|
|
2447
2453
|
this.#extractor.write(`const ${varLocal("rendered_" + renderId)} = `);
|
|
2448
2454
|
}
|
|
2449
2455
|
if (isHTML) {
|
|
2450
|
-
this.#extractor.write(`${varShared("renderNativeTag")}("`).copy(tag.name).write('")');
|
|
2456
|
+
this.#extractor.write(`${varShared("renderNativeTag")}("`).copy(isEmptyRange2(tag.name) ? tagName : tag.name).write('")');
|
|
2451
2457
|
} else if (tagIdentifier) {
|
|
2452
2458
|
this.#extractor.write(
|
|
2453
2459
|
`${varShared(isTemplate ? "renderTemplate" : "renderDynamicTag")}(${tagIdentifier})`
|
|
@@ -2535,7 +2541,7 @@ constructor(_?: Return) {}
|
|
|
2535
2541
|
)`);
|
|
2536
2542
|
break;
|
|
2537
2543
|
case 10 /* AttrNamed */: {
|
|
2538
|
-
const isDefault =
|
|
2544
|
+
const isDefault = isEmptyRange2(attr.name);
|
|
2539
2545
|
const value = attr.value;
|
|
2540
2546
|
const modifierIndex = !isDefault && (!value || value.type === 13 /* AttrValue */) && this.#getNamedAttrModifierIndex(attr);
|
|
2541
2547
|
const defaultMapPosition = isDefault ? attr.name : void 0;
|
|
@@ -3147,7 +3153,7 @@ ${isMutatedVar(tag.parent, valueLiteral) ? `${varLocal("return")}.mutate.` : ""}
|
|
|
3147
3153
|
}
|
|
3148
3154
|
}
|
|
3149
3155
|
#getDynamicTagExpression(tag) {
|
|
3150
|
-
if (tag.name.expressions.length === 1 &&
|
|
3156
|
+
if (tag.name.expressions.length === 1 && isEmptyRange2(tag.name.quasis[0]) && isEmptyRange2(tag.name.quasis[1])) {
|
|
3151
3157
|
return tag.name.expressions[0].value;
|
|
3152
3158
|
}
|
|
3153
3159
|
}
|
|
@@ -3314,7 +3320,7 @@ function stripExt(filename) {
|
|
|
3314
3320
|
function removeNewLines(str) {
|
|
3315
3321
|
return str.replace(REG_NEW_LINE, " ");
|
|
3316
3322
|
}
|
|
3317
|
-
function
|
|
3323
|
+
function isEmptyRange2(range) {
|
|
3318
3324
|
return range.start === range.end;
|
|
3319
3325
|
}
|
|
3320
3326
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/language-tools",
|
|
3
3
|
"description": "Marko Language Tools",
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.21",
|
|
5
5
|
"bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@marko/compiler": "^5.28.4"
|