@xaendar/compiler 0.7.16 → 0.7.17

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.
@@ -517,6 +517,12 @@ function generateElement(node, parentNode, index, compilerContext, anchor) {
517
517
  code: [`const ${nodeName} = _renderElement(${parentNode}, context, ${anchor}, '${tagName}',`],
518
518
  functionsToProcess: /* @__PURE__ */ new Map()
519
519
  };
520
+ switch (tagName) {
521
+ case "svg":
522
+ retval.code.push("context.createElement = createSVGElement");
523
+ break;
524
+ case "math": retval.code.push("context.createElement = createMATHMLElement");
525
+ }
520
526
  attributes.length ? retval.code.push(...indent([
521
527
  "[",
522
528
  ...indent(attributes),
@@ -527,6 +533,10 @@ function generateElement(node, parentNode, index, compilerContext, anchor) {
527
533
  ...indent(events),
528
534
  "]"
529
535
  ]), ");") : retval.code[retval.code.length - 1] = `${retval.code[retval.code.length - 1]} []);`;
536
+ switch (tagName) {
537
+ case "svg":
538
+ case "math": retval.code.push("context.createElement = createElement");
539
+ }
530
540
  if (node.children.length) {
531
541
  retval.functionsToProcess.set(`${nodeName}Children`, {
532
542
  fn: {
@@ -861,16 +871,13 @@ var Generator = class {
861
871
  renderFunctions.push(...indent(["return context;"]), "}");
862
872
  for (const [key, fnData] of this._nodeToProcess.entries()) {
863
873
  const { node, parentNode, context, precode, anchor } = fnData.fn;
864
- renderFunctions.push(`\n${key}(${fnData.args?.join(", ")}) {`, ...indent([
865
- "const context = new Context(this, parentContext);",
866
- ...node.children.map((child, i) => {
867
- const { code, functionsToProcess } = this._processNode(child, parentNode, i.toString(), context, anchor ?? null);
868
- functionsToProcess?.forEach((value, key) => this._nodeToProcess.set(key, value));
869
- if (precode) code.unshift(precode);
870
- return code;
871
- }).flat(),
872
- fnData.fn.isForBody ? "return { context, update };" : "return context;"
873
- ]), "}");
874
+ renderFunctions.push(`\n${key}(${fnData.args?.join(", ")}) {`, ...indent(["const context = new Context(this, parentContext);"]));
875
+ if (precode) renderFunctions.push(indent(precode));
876
+ renderFunctions.push(...indent([...node.children.map((child, i) => {
877
+ const { code, functionsToProcess } = this._processNode(child, parentNode, i.toString(), context, anchor ?? null);
878
+ functionsToProcess?.forEach((value, key) => this._nodeToProcess.set(key, value));
879
+ return code;
880
+ }).flat(), fnData.fn.isForBody ? "return { context, update };" : "return context;"]), "}");
874
881
  }
875
882
  return renderFunctions.join("\n");
876
883
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaendar/compiler",
3
- "version": "0.7.16",
3
+ "version": "0.7.17",
4
4
  "description": "A library for transpiling Xaendar Templates into JavaScript code",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -16,8 +16,8 @@
16
16
  }
17
17
  },
18
18
  "dependencies": {
19
- "@xaendar/common": "0.7.16",
20
- "@xaendar/types": "0.7.16",
19
+ "@xaendar/common": "0.7.17",
20
+ "@xaendar/types": "0.7.17",
21
21
  "typescript": "^6.0.3"
22
22
  }
23
23
  }