marko 6.0.39 → 6.0.40

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.
@@ -9936,13 +9936,21 @@ function isNonHTMLText(placeholder) {
9936
9936
  // src/translator/visitors/placeholder.ts
9937
9937
  var kNodeBinding4 = Symbol("placeholder node binding");
9938
9938
  var kSiblingText = Symbol("placeholder has sibling text");
9939
+ var kSharedText = Symbol(
9940
+ "placeholder will merge its visitor with a another node"
9941
+ );
9939
9942
  var placeholder_default = {
9940
9943
  analyze(placeholder) {
9941
9944
  if (isNonHTMLText(placeholder)) return;
9942
9945
  const { node } = placeholder;
9943
9946
  const valueExtra = evaluate(node.value);
9944
9947
  const { confident, computed } = valueExtra;
9945
- if (!(confident && (node.escape || isVoid2(computed)))) {
9948
+ if (confident && isVoid2(computed)) return;
9949
+ if (isStaticText(node)) {
9950
+ if (isStaticText(getPrev(placeholder))) {
9951
+ (node.extra ??= {})[kSharedText] = true;
9952
+ }
9953
+ } else {
9946
9954
  const section = getOrCreateSection(placeholder);
9947
9955
  const nodeBinding = (node.extra ??= {})[kNodeBinding4] = createBinding(
9948
9956
  "#text",
@@ -9970,12 +9978,12 @@ var placeholder_default = {
9970
9978
  const nodeBinding = extra[kNodeBinding4];
9971
9979
  const canWriteHTML = isHTML || confident && node.escape;
9972
9980
  const method = canWriteHTML ? node.escape ? "escapeXML" : "toString" : node.escape ? "data" : "html";
9973
- const section = getSection(placeholder);
9974
- const markerSerializeReason = nodeBinding && getBindingSerializeReason(section, nodeBinding);
9975
- const siblingText = extra[kSiblingText];
9976
9981
  if (confident && canWriteHTML) {
9977
9982
  write2`${getHTMLRuntime()[method](computed)}`;
9978
9983
  } else {
9984
+ const section = getSection(placeholder);
9985
+ const siblingText = extra[kSiblingText];
9986
+ const markerSerializeReason = nodeBinding && getBindingSerializeReason(section, nodeBinding);
9979
9987
  if (siblingText === 1 /* Before */) {
9980
9988
  if (isHTML && markerSerializeReason) {
9981
9989
  if (markerSerializeReason === true || markerSerializeReason.state) {
@@ -10020,7 +10028,9 @@ var placeholder_default = {
10020
10028
  );
10021
10029
  }
10022
10030
  }
10023
- enterShallow(placeholder);
10031
+ if (!extra[kSharedText]) {
10032
+ enterShallow(placeholder);
10033
+ }
10024
10034
  placeholder.remove();
10025
10035
  }
10026
10036
  }
@@ -10066,6 +10076,31 @@ function analyzeSiblingText(placeholder) {
10066
10076
  function isVoid2(value) {
10067
10077
  return value == null || value === false;
10068
10078
  }
10079
+ function isStaticText(node) {
10080
+ switch (node?.type) {
10081
+ case "MarkoText":
10082
+ return true;
10083
+ case "MarkoPlaceholder": {
10084
+ if (node.escape) {
10085
+ const { confident, computed } = evaluate(node.value);
10086
+ return confident && !isVoid2(computed);
10087
+ } else {
10088
+ return false;
10089
+ }
10090
+ }
10091
+ }
10092
+ }
10093
+ function getPrev(path5) {
10094
+ let prev = path5.getPrevSibling();
10095
+ while (prev.node && (prev.isMarkoComment() || prev.isMarkoPlaceholder() && isEmptyPlaceholder(prev.node))) {
10096
+ prev = prev.getPrevSibling();
10097
+ }
10098
+ return prev.node;
10099
+ }
10100
+ function isEmptyPlaceholder(placeholder) {
10101
+ const { confident, computed } = evaluate(placeholder.value);
10102
+ return confident && isVoid2(computed);
10103
+ }
10069
10104
 
10070
10105
  // src/translator/visitors/referenced-identifier.ts
10071
10106
  var import_compiler54 = require("@marko/compiler");
@@ -2,6 +2,7 @@ import { types as t } from "@marko/compiler";
2
2
  import { type Binding } from "../util/references";
3
3
  declare const kNodeBinding: unique symbol;
4
4
  declare const kSiblingText: unique symbol;
5
+ declare const kSharedText: unique symbol;
5
6
  declare enum SiblingText {
6
7
  None = 0,
7
8
  Before = 1,
@@ -11,6 +12,7 @@ declare module "@marko/compiler/dist/types" {
11
12
  interface MarkoPlaceholderExtra {
12
13
  [kNodeBinding]?: Binding;
13
14
  [kSiblingText]?: SiblingText;
15
+ [kSharedText]?: true;
14
16
  }
15
17
  }
16
18
  declare const _default: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.39",
3
+ "version": "6.0.40",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",