marko 6.0.91 → 6.0.92

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.
@@ -2591,8 +2591,8 @@ var import_compiler13 = require("@marko/compiler");
2591
2591
  function normalizeStringExpression(parts) {
2592
2592
  const strs = [];
2593
2593
  const exprs = [];
2594
- let curStr = parts[0];
2595
- for (let i = 1; i < parts.length; i++) {
2594
+ let curStr = "";
2595
+ for (let i = 0; i < parts.length; i++) {
2596
2596
  let content = parts[i];
2597
2597
  if (typeof content === "object") {
2598
2598
  if (import_compiler13.types.isStringLiteral(content)) {
@@ -4166,7 +4166,8 @@ function replaceEffectNode(node) {
4166
4166
  function replaceBindingReadNode(node) {
4167
4167
  switch (node.type) {
4168
4168
  case "Identifier":
4169
- case "MemberExpression": {
4169
+ case "MemberExpression":
4170
+ case "OptionalMemberExpression": {
4170
4171
  return getReadReplacement(node);
4171
4172
  }
4172
4173
  }
@@ -4576,7 +4577,8 @@ function replaceNode(node, container) {
4576
4577
  function replaceBindingReadNode2(node) {
4577
4578
  switch (node.type) {
4578
4579
  case "Identifier":
4579
- case "MemberExpression": {
4580
+ case "MemberExpression":
4581
+ case "OptionalMemberExpression": {
4580
4582
  const { extra } = node;
4581
4583
  if (extra && !(extra.read && !extra.read.binding.declared || extra.binding && !extra.binding.declared)) {
4582
4584
  return getReadReplacement(node);
@@ -4781,20 +4783,19 @@ function getChangeHandler(tag, attr) {
4781
4783
  changeAttrName,
4782
4784
  withPreviousLocation(import_compiler25.types.identifier(changeHandlerId), attr.value)
4783
4785
  );
4784
- } else if (import_compiler25.types.isMemberExpression(attr.value)) {
4786
+ } else if (import_compiler25.types.isMemberExpression(attr.value) || import_compiler25.types.isOptionalMemberExpression(attr.value)) {
4785
4787
  const prop = attr.value.property;
4786
4788
  if (!import_compiler25.types.isPrivateName(attr.value.property)) {
4789
+ const memberObj = import_compiler25.types.cloneNode(attr.value.object);
4790
+ const memberProp = prop.type === "Identifier" ? withPreviousLocation(import_compiler25.types.identifier(prop.name + "Change"), prop) : import_compiler25.types.binaryExpression(
4791
+ "+",
4792
+ import_compiler25.types.cloneNode(prop),
4793
+ import_compiler25.types.stringLiteral("Change")
4794
+ );
4795
+ const computed = memberProp.type !== "Identifier";
4787
4796
  return import_compiler25.types.markoAttribute(
4788
4797
  changeAttrName,
4789
- import_compiler25.types.memberExpression(
4790
- import_compiler25.types.cloneNode(attr.value.object),
4791
- prop.type === "Identifier" ? withPreviousLocation(import_compiler25.types.identifier(prop.name + "Change"), prop) : import_compiler25.types.binaryExpression(
4792
- "+",
4793
- import_compiler25.types.cloneNode(prop),
4794
- import_compiler25.types.stringLiteral("Change")
4795
- ),
4796
- prop.type !== "Identifier"
4797
- )
4798
+ attr.value.optional ? import_compiler25.types.optionalMemberExpression(memberObj, memberProp, computed, true) : import_compiler25.types.memberExpression(memberObj, memberProp, computed)
4798
4799
  );
4799
4800
  }
4800
4801
  }
@@ -8077,7 +8078,8 @@ function trackReference(referencePath, binding) {
8077
8078
  let propPath = binding.name;
8078
8079
  while (true) {
8079
8080
  const { parent } = root;
8080
- if (!import_compiler35.types.isMemberExpression(parent)) break;
8081
+ if (!import_compiler35.types.isMemberExpression(parent) && !import_compiler35.types.isOptionalMemberExpression(parent))
8082
+ break;
8081
8083
  const prop = getMemberExpressionPropString(parent);
8082
8084
  if (prop === void 0) break;
8083
8085
  if (reference.upstreamAlias && reference.excludeProperties !== void 0 && !propsUtil.has(reference.excludeProperties, prop)) {
@@ -1,3 +1,3 @@
1
1
  import { types as t } from "@marko/compiler";
2
2
  import { type Binding } from "./references";
3
- export declare function getDeclaredBindingExpression(binding: Binding): t.Identifier | t.OptionalMemberExpression | t.MemberExpression;
3
+ export declare function getDeclaredBindingExpression(binding: Binding): t.Identifier | t.MemberExpression | t.OptionalMemberExpression;
@@ -108,7 +108,7 @@ export declare function getDebugName(binding: Binding): string;
108
108
  export declare function getDebugNames(refs: ReferencedBindings): string;
109
109
  export declare function getSectionInstancesAccessor(section: Section): string;
110
110
  export declare function getSectionInstancesAccessorLiteral(section: Section): t.StringLiteral | t.NumericLiteral | undefined;
111
- export declare function getReadReplacement(node: t.Identifier | t.MemberExpression): t.Node | undefined;
111
+ export declare function getReadReplacement(node: t.Identifier | t.MemberExpression | t.OptionalMemberExpression): t.Node | undefined;
112
112
  export interface ReferencedExtra extends t.NodeExtra {
113
113
  section: Section;
114
114
  fnExtra?: FnExtra;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.91",
3
+ "version": "6.0.92",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",