@canvasengine/compiler 2.0.0-beta.17 → 2.0.0-beta.19

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/grammar.pegjs CHANGED
@@ -298,9 +298,17 @@ ifCondition "if condition"
298
298
  }
299
299
 
300
300
  tagName "tag name"
301
- = segments:([a-zA-Z][a-zA-Z0-9]* ("." [a-zA-Z][a-zA-Z0-9]*)*) {
302
- return text();
303
- }
301
+ = tagExpression
302
+
303
+ tagExpression "tag expression"
304
+ = first:tagPart rest:("." tagPart)* {
305
+ return text();
306
+ }
307
+
308
+ tagPart "tag part"
309
+ = name:[a-zA-Z][a-zA-Z0-9]* args:("(" functionArgs? ")")? {
310
+ return text();
311
+ }
304
312
 
305
313
  attributeName "attribute name"
306
314
  = [a-zA-Z][a-zA-Z0-9-]* { return text(); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canvasengine/compiler",
3
- "version": "2.0.0-beta.17",
3
+ "version": "2.0.0-beta.19",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -51,11 +51,49 @@ describe("Compiler", () => {
51
51
  expect(output).toBe(`h(Canvas)`);
52
52
  });
53
53
 
54
- test("should compile component with dot notation", () => {
55
- const input = `<MyComp.test />`;
56
- const output = parser.parse(input);
57
- expect(output).toBe(`h(MyComp.test)`);
58
- });
54
+ describe("Dot notation", () => {
55
+ test("should compile component with dot notation", () => {
56
+ const input = `<MyComp.test />`;
57
+ const output = parser.parse(input);
58
+ expect(output).toBe(`h(MyComp.test)`);
59
+ });
60
+
61
+ test("object function call", () => {
62
+ const input = `<MyComp.test() />`;
63
+ const output = parser.parse(input);
64
+ expect(output).toBe(`h(MyComp.test())`);
65
+ });
66
+
67
+ test("function call with return object", () => {
68
+ const input = `<MyComp().test />`;
69
+ const output = parser.parse(input);
70
+ expect(output).toBe(`h(MyComp().test)`);
71
+ });
72
+
73
+ test("function call with return object and params", () => {
74
+ const input = `<MyComp().test(x, y) />`;
75
+ const output = parser.parse(input);
76
+ expect(output).toBe(`h(MyComp().test(x, y))`);
77
+ });
78
+
79
+ test("function call and params with return object and", () => {
80
+ const input = `<MyComp(x, y).test />`;
81
+ const output = parser.parse(input);
82
+ expect(output).toBe(`h(MyComp(x, y).test)`);
83
+ });
84
+
85
+ test("function call", () => {
86
+ const input = `<MyComp() />`;
87
+ const output = parser.parse(input);
88
+ expect(output).toBe(`h(MyComp())`);
89
+ });
90
+
91
+ test("function call and params", () => {
92
+ const input = `<MyComp(x, y) />`;
93
+ const output = parser.parse(input);
94
+ expect(output).toBe(`h(MyComp(x, y))`);
95
+ });
96
+ })
59
97
 
60
98
  test("should compile component with dynamic attribute", () => {
61
99
  const input = `<Canvas width={x} />`;