@marko/language-tools 2.4.0 → 2.4.1

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 CHANGED
@@ -1964,7 +1964,7 @@ constructor(_?: Return) {}
1964
1964
  this.#extractor.copy(returned);
1965
1965
  this.#extractor.write(");\n");
1966
1966
  }
1967
- #writeChildren(parent, children) {
1967
+ #writeChildren(parent, children, skipRenderId = false) {
1968
1968
  var _a, _b;
1969
1969
  const last = children.length - 1;
1970
1970
  let returnTag;
@@ -1979,27 +1979,31 @@ constructor(_?: Return) {}
1979
1979
  break;
1980
1980
  case "if": {
1981
1981
  const alternates = IF_TAG_ALTERNATES.get(child);
1982
- let renderId = this.#getRenderId(child);
1983
- if (!renderId && alternates) {
1984
- for (const { node } of alternates) {
1985
- if (renderId = this.#getRenderId(node)) break;
1982
+ let renderId;
1983
+ if (!skipRenderId) {
1984
+ renderId = this.#getRenderId(child);
1985
+ if (!renderId && alternates) {
1986
+ for (const { node } of alternates) {
1987
+ if (renderId = this.#getRenderId(node)) break;
1988
+ }
1986
1989
  }
1987
- }
1988
- if (renderId) {
1989
- this.#extractor.write(
1990
- `${varShared("assertRendered")}(${varShared(
1991
- "rendered"
1992
- )}, ${renderId}, (() => {
1990
+ if (renderId) {
1991
+ this.#extractor.write(
1992
+ `${varShared("assertRendered")}(${varShared(
1993
+ "rendered"
1994
+ )}, ${renderId}, (() => {
1993
1995
  `
1994
- );
1996
+ );
1997
+ }
1995
1998
  }
1996
1999
  this.#writeComments(child);
1997
2000
  this.#extractor.write("if (").copy(
1998
2001
  this.#getRangeWithoutTrailingComma((_a = child.args) == null ? void 0 : _a.value) || this.#getAttrValue(child, ATTR_UNAMED2) || "undefined"
1999
2002
  ).write(") {\n");
2000
- if (child.body) {
2003
+ const ifBody = this.#processBody(child);
2004
+ if (ifBody == null ? void 0 : ifBody.renderBody) {
2001
2005
  const localBindings = getHoistSources(child);
2002
- this.#writeChildren(child, child.body);
2006
+ this.#writeChildren(child, ifBody.renderBody, true);
2003
2007
  if (localBindings) {
2004
2008
  this.#extractor.write("return {\nscope:");
2005
2009
  this.#writeObjectKeys(localBindings);
@@ -2018,9 +2022,10 @@ constructor(_?: Return) {}
2018
2022
  } else {
2019
2023
  this.#extractor.write("\n} else if (undefined) {\n");
2020
2024
  }
2021
- if (node.body) {
2025
+ const alternateBody = this.#processBody(node);
2026
+ if (alternateBody == null ? void 0 : alternateBody.renderBody) {
2022
2027
  const localBindings = getHoistSources(node);
2023
- this.#writeChildren(node, node.body);
2028
+ this.#writeChildren(node, alternateBody.renderBody, true);
2024
2029
  if (localBindings) {
2025
2030
  this.#extractor.write("return {\nscope:");
2026
2031
  this.#writeObjectKeys(localBindings);
package/dist/index.mjs CHANGED
@@ -1928,7 +1928,7 @@ constructor(_?: Return) {}
1928
1928
  this.#extractor.copy(returned);
1929
1929
  this.#extractor.write(");\n");
1930
1930
  }
1931
- #writeChildren(parent, children) {
1931
+ #writeChildren(parent, children, skipRenderId = false) {
1932
1932
  var _a, _b;
1933
1933
  const last = children.length - 1;
1934
1934
  let returnTag;
@@ -1943,27 +1943,31 @@ constructor(_?: Return) {}
1943
1943
  break;
1944
1944
  case "if": {
1945
1945
  const alternates = IF_TAG_ALTERNATES.get(child);
1946
- let renderId = this.#getRenderId(child);
1947
- if (!renderId && alternates) {
1948
- for (const { node } of alternates) {
1949
- if (renderId = this.#getRenderId(node)) break;
1946
+ let renderId;
1947
+ if (!skipRenderId) {
1948
+ renderId = this.#getRenderId(child);
1949
+ if (!renderId && alternates) {
1950
+ for (const { node } of alternates) {
1951
+ if (renderId = this.#getRenderId(node)) break;
1952
+ }
1950
1953
  }
1951
- }
1952
- if (renderId) {
1953
- this.#extractor.write(
1954
- `${varShared("assertRendered")}(${varShared(
1955
- "rendered"
1956
- )}, ${renderId}, (() => {
1954
+ if (renderId) {
1955
+ this.#extractor.write(
1956
+ `${varShared("assertRendered")}(${varShared(
1957
+ "rendered"
1958
+ )}, ${renderId}, (() => {
1957
1959
  `
1958
- );
1960
+ );
1961
+ }
1959
1962
  }
1960
1963
  this.#writeComments(child);
1961
1964
  this.#extractor.write("if (").copy(
1962
1965
  this.#getRangeWithoutTrailingComma((_a = child.args) == null ? void 0 : _a.value) || this.#getAttrValue(child, ATTR_UNAMED2) || "undefined"
1963
1966
  ).write(") {\n");
1964
- if (child.body) {
1967
+ const ifBody = this.#processBody(child);
1968
+ if (ifBody == null ? void 0 : ifBody.renderBody) {
1965
1969
  const localBindings = getHoistSources(child);
1966
- this.#writeChildren(child, child.body);
1970
+ this.#writeChildren(child, ifBody.renderBody, true);
1967
1971
  if (localBindings) {
1968
1972
  this.#extractor.write("return {\nscope:");
1969
1973
  this.#writeObjectKeys(localBindings);
@@ -1982,9 +1986,10 @@ constructor(_?: Return) {}
1982
1986
  } else {
1983
1987
  this.#extractor.write("\n} else if (undefined) {\n");
1984
1988
  }
1985
- if (node.body) {
1989
+ const alternateBody = this.#processBody(node);
1990
+ if (alternateBody == null ? void 0 : alternateBody.renderBody) {
1986
1991
  const localBindings = getHoistSources(node);
1987
- this.#writeChildren(node, node.body);
1992
+ this.#writeChildren(node, alternateBody.renderBody, true);
1988
1993
  if (localBindings) {
1989
1994
  this.#extractor.write("return {\nscope:");
1990
1995
  this.#writeObjectKeys(localBindings);
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.4.0",
4
+ "version": "2.4.1",
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"