@ibyar/elements 0.4.2 → 0.5.0

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/ast/dom.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare class ElementAttribute<N, V> extends Attribute<N, V> {
7
7
  }
8
8
  export declare class LiveAttribute extends Attribute<string, string> {
9
9
  }
10
+ export declare function createLiveAttribute(name: string, value: string): LiveAttribute;
10
11
  export declare class TextContent extends Attribute<'textContent', string> {
11
12
  static propName: 'textContent';
12
13
  constructor(text: string);
@@ -24,36 +25,43 @@ export declare class BaseNode {
24
25
  outputs?: ElementAttribute<string, string>[];
25
26
  twoWayBinding?: LiveAttribute[];
26
27
  templateAttrs?: LiveAttribute[];
28
+ attributeDirectives?: DomAttributeDirectiveNode[];
27
29
  addAttribute(attrName: string, value?: string | number | boolean | object): void;
28
30
  addInput(attrName: string, valueSource: string): void;
29
31
  addOutput(eventName: string, handlerSource: string): void;
30
32
  addTwoWayBinding(eventName: string, handlerSource: string): void;
31
33
  addTemplateAttr(attrName: string, valueSource: string): void;
32
34
  }
33
- export declare class DOMParentNode extends BaseNode {
34
- children: DOMChild[];
35
- addChild(child: DOMChild): void;
35
+ export declare class DomAttributeDirectiveNode extends BaseNode {
36
+ name: string;
37
+ attributeDirectives: undefined;
38
+ constructor(name: string);
39
+ }
40
+ export declare class DomParentNode extends BaseNode {
41
+ children?: DomChild[];
42
+ addChild(child: DomChild): void;
36
43
  addTextChild(text: string): void;
37
44
  }
38
- export declare class DOMFragmentNode extends DOMParentNode {
39
- constructor(children?: DOMChild[]);
45
+ export declare class DomFragmentNode extends DomParentNode {
46
+ constructor(children?: DomChild[]);
40
47
  }
41
- export declare class DOMElementNode extends DOMParentNode {
48
+ export declare class DomElementNode extends DomParentNode {
42
49
  tagName: string;
43
50
  is?: string;
44
- templateRefName: Attribute<string, string | undefined>;
51
+ templateRefName?: Attribute<string, string | undefined>;
45
52
  constructor(tagName: string, is?: string);
46
53
  setTagName(tagName: string): void;
47
54
  setTemplateRefName(name: string, value?: string): void;
48
55
  }
49
- export declare class DOMDirectiveNode extends BaseNode {
56
+ export declare class DomStructuralDirectiveNode extends BaseNode {
50
57
  name: string;
51
- value: string;
52
- node: DOMNode;
53
- constructor(name: string, value: string, node: DOMNode);
58
+ value?: string;
59
+ node: DomNode;
60
+ constructor(name: string, node: DomNode, value?: string);
54
61
  }
55
- export declare type DOMChild = DOMElementNode | DOMDirectiveNode | CommentNode | TextContent | LiveTextContent;
56
- export declare type DOMNode = DOMFragmentNode | DOMElementNode | DOMDirectiveNode | CommentNode | TextContent | LiveTextContent;
57
- export declare type DOMRenderNode<T> = (model: T) => DOMNode;
62
+ export declare function isDOMDirectiveNode(node: object): node is DomStructuralDirectiveNode;
63
+ export declare type DomChild = DomElementNode | DomStructuralDirectiveNode | CommentNode | TextContent | LiveTextContent;
64
+ export declare type DomNode = DomFragmentNode | DomElementNode | DomStructuralDirectiveNode | CommentNode | TextContent | LiveTextContent;
65
+ export declare type DomRenderNode<T> = (model: T) => DomNode;
58
66
  export declare function parseTextChild(text: string): Array<TextContent | LiveTextContent>;
59
67
  export declare function parseStringTemplate(text: string): string;
package/ast/dom.js CHANGED
@@ -8,6 +8,9 @@ export class ElementAttribute extends Attribute {
8
8
  }
9
9
  export class LiveAttribute extends Attribute {
10
10
  }
11
+ export function createLiveAttribute(name, value) {
12
+ return new LiveAttribute(name, value);
13
+ }
11
14
  export class TextContent extends Attribute {
12
15
  constructor(text) {
13
16
  super(TextContent.propName, text);
@@ -75,7 +78,13 @@ export class BaseNode {
75
78
  }
76
79
  }
77
80
  }
78
- export class DOMParentNode extends BaseNode {
81
+ export class DomAttributeDirectiveNode extends BaseNode {
82
+ constructor(name) {
83
+ super();
84
+ this.name = name;
85
+ }
86
+ }
87
+ export class DomParentNode extends BaseNode {
79
88
  addChild(child) {
80
89
  if (this.children) {
81
90
  this.children.push(child);
@@ -85,13 +94,11 @@ export class DOMParentNode extends BaseNode {
85
94
  }
86
95
  }
87
96
  addTextChild(text) {
88
- if (!this.children) {
89
- this.children = [];
90
- }
91
- parseTextChild(text).forEach(childText => this.children.push(childText));
97
+ const children = (this.children ??= []);
98
+ parseTextChild(text).forEach(childText => children.push(childText));
92
99
  }
93
100
  }
94
- export class DOMFragmentNode extends DOMParentNode {
101
+ export class DomFragmentNode extends DomParentNode {
95
102
  constructor(children) {
96
103
  super();
97
104
  if (children) {
@@ -99,7 +106,7 @@ export class DOMFragmentNode extends DOMParentNode {
99
106
  }
100
107
  }
101
108
  }
102
- export class DOMElementNode extends DOMParentNode {
109
+ export class DomElementNode extends DomParentNode {
103
110
  constructor(tagName, is) {
104
111
  super();
105
112
  this.tagName = tagName;
@@ -114,14 +121,17 @@ export class DOMElementNode extends DOMParentNode {
114
121
  this.templateRefName = new Attribute(name, value);
115
122
  }
116
123
  }
117
- export class DOMDirectiveNode extends BaseNode {
118
- constructor(name, value, node) {
124
+ export class DomStructuralDirectiveNode extends BaseNode {
125
+ constructor(name, node, value) {
119
126
  super();
120
127
  this.name = name;
121
- this.value = value;
122
128
  this.node = node;
129
+ this.value = value;
123
130
  }
124
131
  }
132
+ export function isDOMDirectiveNode(node) {
133
+ return node instanceof DomStructuralDirectiveNode;
134
+ }
125
135
  export function parseTextChild(text) {
126
136
  let all = [];
127
137
  let temp = text;
package/ast/dom.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"dom.js","sourceRoot":"","sources":["../../../src/elements/ast/dom.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,SAAS;IACrB,YAAmB,IAAO,EAAS,KAAQ;QAAxB,SAAI,GAAJ,IAAI,CAAG;QAAS,UAAK,GAAL,KAAK,CAAG;IAAI,CAAC;CAChD;AAED,MAAM,OAAO,gBAAuB,SAAQ,SAAe;CAAI;AAK/D,MAAM,OAAO,aAAc,SAAQ,SAAyB;CAAI;AAKhE,MAAM,OAAO,WAAY,SAAQ,SAAgC;IAEhE,YAAY,IAAY;QACvB,KAA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C,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5G,OAAO,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AACxB,CAAC","sourcesContent":["\n/**\n * a normal attribute with its source value without any binding.\n */\nexport class Attribute<N, V> {\n\tconstructor(public name: N, public value: V) { }\n}\n\nexport class ElementAttribute<N, V> extends Attribute<N, V> { }\n\n/**\n * an attribute with its source value for binding\n */\nexport class LiveAttribute extends Attribute<string, string> { }\n\n/**\n * a normal text\n */\nexport class TextContent extends Attribute<'textContent', string> {\n\tstatic propName: 'textContent' = 'textContent';\n\tconstructor(text: string) {\n\t\tsuper(TextContent.propName, text);\n\t}\n}\n\n/**\n * a text that its content is binding to variable from the component model.\n */\nexport class LiveTextContent extends TextContent { }\n\nexport function isLiveTextContent(text: object): text is LiveTextContent {\n\treturn text instanceof LiveTextContent;\n}\n\n/**\n * to comment in dom\n */\nexport class CommentNode {\n\tconstructor(public comment: string) { }\n}\n\n\nexport class BaseNode {\n\n\t/**\n\t * hold static attr and event that will resolve normally from the global window.\n\t */\n\tattributes?: ElementAttribute<string, string | number | boolean | object>[];\n\n\t/**\n\t * hold the attrs/inputs name marked as one way binding\n\t */\n\tinputs?: LiveAttribute[];\n\n\t/**\n\t * hold the name of events that should be connected to a listener\n\t */\n\toutputs?: ElementAttribute<string, string>[];\n\n\t/**\n\t * hold the name of attributes marked for 2 way data binding\n\t */\n\ttwoWayBinding?: LiveAttribute[];\n\n\t/**\n\t * directive attribute\n\t */\n\ttemplateAttrs?: LiveAttribute[];\n\n\taddAttribute(attrName: string, value?: string | number | boolean | object) {\n\t\tif (this.attributes) {\n\t\t\tthis.attributes.push(new ElementAttribute(attrName, value ?? true));\n\t\t} else {\n\t\t\tthis.attributes = [new ElementAttribute(attrName, value ?? true)];\n\t\t}\n\t}\n\n\taddInput(attrName: string, valueSource: string) {\n\t\tif (this.inputs) {\n\t\t\tthis.inputs.push(new LiveAttribute(attrName, valueSource));\n\t\t} else {\n\t\t\tthis.inputs = [new LiveAttribute(attrName, valueSource)];\n\t\t}\n\t}\n\n\taddOutput(eventName: string, handlerSource: string) {\n\t\tif (this.outputs) {\n\t\t\tthis.outputs.push(new LiveAttribute(eventName, handlerSource));\n\t\t} else {\n\t\t\tthis.outputs = [new LiveAttribute(eventName, handlerSource)];\n\t\t}\n\t}\n\n\taddTwoWayBinding(eventName: string, handlerSource: string) {\n\t\tif (this.twoWayBinding) {\n\t\t\tthis.twoWayBinding.push(new LiveAttribute(eventName, handlerSource));\n\t\t} else {\n\t\t\tthis.twoWayBinding = [new LiveAttribute(eventName, handlerSource)];\n\t\t}\n\t}\n\n\taddTemplateAttr(attrName: string, valueSource: string) {\n\t\tvalueSource = valueSource.trim();\n\t\tif (/^\\{\\{(.+)\\}\\}$/g.test(valueSource)) {\n\t\t\t// as one way binding\n\t\t\tconst substring = valueSource.substring(2, valueSource.length - 2);\n\t\t\tif (!(/\\{\\{(.+)\\}\\}/g).test(substring)) {\n\t\t\t\tthis.addInput(attrName, substring);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t// as string \n\t\tvalueSource = parseStringTemplate(valueSource);\n\t\tif (this.templateAttrs) {\n\t\t\tthis.templateAttrs.push(new LiveAttribute(attrName, valueSource));\n\t\t} else {\n\t\t\tthis.templateAttrs = [new LiveAttribute(attrName, valueSource)];\n\t\t}\n\t}\n\n}\n\nexport class DOMParentNode extends BaseNode {\n\t/**\n\t * element children list\n\t */\n\tchildren: DOMChild[];\n\n\taddChild(child: DOMChild) {\n\t\tif (this.children) {\n\t\t\tthis.children.push(child);\n\t\t} else {\n\t\t\tthis.children = [child];\n\t\t}\n\t}\n\n\taddTextChild(text: string) {\n\t\tif (!this.children) {\n\t\t\tthis.children = [];\n\t\t}\n\t\tparseTextChild(text).forEach(childText => this.children.push(childText));\n\t}\n\n}\n\n/**\n * parent for a list of elements \n */\nexport class DOMFragmentNode extends DOMParentNode {\n\tconstructor(children?: DOMChild[]) {\n\t\tsuper();\n\t\tif (children) {\n\t\t\tthis.children = children;\n\t\t}\n\t}\n}\nexport class DOMElementNode extends DOMParentNode {\n\n\t/**\n\t * the tag name of the element \n\t */\n\ttagName: string;\n\n\t/**\n\t * used to upgrade an element to another custom-element name\n\t */\n\tis?: string;\n\n\t/**\n\t * a given name for element\n\t */\n\ttemplateRefName: Attribute<string, string | undefined>;\n\n\tconstructor(tagName: string, is?: string) {\n\t\tsuper();\n\t\tthis.tagName = tagName;\n\t\tif (is) {\n\t\t\tthis.is = is;\n\t\t}\n\t}\n\n\tsetTagName(tagName: string) {\n\t\tthis.tagName = tagName;\n\t}\n\n\tsetTemplateRefName(name: string, value?: string) {\n\t\tthis.templateRefName = new Attribute(name, value);\n\t}\n\n}\n\n\n/**\n * structural directive \n */\nexport class DOMDirectiveNode extends BaseNode {\n\n\t/**\n\t * name of the directive \n\t */\n\tname: string;\n\n\t/**\n\t * value of the directive \n\t */\n\tvalue: string;\n\n\t/**\n\t * the value of the template node, that this directive going to host-on \n\t */\n\tnode: DOMNode;\n\n\tconstructor(name: string, value: string, node: DOMNode) {\n\t\tsuper();\n\t\tthis.name = name;\n\t\tthis.value = value;\n\t\tthis.node = node;\n\t}\n}\nexport type DOMChild = DOMElementNode | DOMDirectiveNode | CommentNode | TextContent | LiveTextContent;\n\nexport type DOMNode = DOMFragmentNode | DOMElementNode | DOMDirectiveNode | CommentNode | TextContent | LiveTextContent;\n\nexport type DOMRenderNode<T> = (model: T) => DOMNode;\n\nexport function parseTextChild(text: string): Array<TextContent | LiveTextContent> {\n\t// split from end with '}}', then search for the first '{{'\n\tlet all: (TextContent | LiveTextContent)[] = [];\n\tlet temp = text;\n\tlet last = temp.lastIndexOf('}}');\n\tlet first: number;\n\twhile (last > -1) {\n\t\tfirst = text.lastIndexOf('{{', last);\n\t\tif (first > -1) {\n\t\t\tlet lastPart = temp.substring(last + 2);\n\t\t\tif (lastPart) {\n\t\t\t\tall.push(new TextContent(lastPart));\n\t\t\t}\n\t\t\tconst liveText = new LiveTextContent(temp.substring(first + 2, last));\n\t\t\tall.push(liveText);\n\t\t\ttemp = temp.substring(0, first);\n\t\t\tlast = temp.lastIndexOf('}}');\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (temp) {\n\t\tall.push(new TextContent(temp));\n\t}\n\treturn all.reverse();\n}\n\nexport function parseStringTemplate(text: string): string {\n\tconst node = parseTextChild(text);\n\tconst map = node.map(str => (str instanceof LiveTextContent ? '${' + str.value + '}' : str.value)).join('');\n\treturn '`' + map + '`';\n}\n"]}
1
+ {"version":3,"file":"dom.js","sourceRoot":"","sources":["../../../src/elements/ast/dom.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,SAAS;IACrB,YAAmB,IAAO,EAAS,KAAQ;QAAxB,SAAI,GAAJ,IAAI,CAAG;QAAS,UAAK,GAAL,KAAK,CAAG;IAAI,CAAC;CAChD;AAED,MAAM,OAAO,gBAAuB,SAAQ,SAAe;CAAI;AAK/D,MAAM,OAAO,aAAc,SAAQ,SAAyB;CAAI;AAQhE,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,KAAa;IAC9D,OAAO,IAAI,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC;AAKD,MAAM,OAAO,WAAY,SAAQ,SAAgC;IAEhE,YAAY,IAAY;QACvB,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;;AAHM,oBAAQ,GAAkB,aAAa,CAAC;AAShD,MAAM,OAAO,eAAgB,SAAQ,WAAW;CAAI;AAEpD,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC7C,OAAO,IAAI,YAAY,eAAe,CAAC;AACxC,CAAC;AAKD,MAAM,OAAO,WAAW;IACvB,YAAmB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAI,CAAC;CACvC;AAGD,MAAM,OAAO,QAAQ;IAgCpB,YAAY,CAAC,QAAgB,EAAE,KAA0C;QACxE,IAAI,IAAI,C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EAAE,IAAI,CAAC,CAAC;QACrC,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;YACf,IAAI,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;YACxC,IAAI,QAAQ,EAAE;gBACb,GAAG,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;aACpC;YACD,MAAM,QAAQ,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;YACtE,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACnB,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAChC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SAC9B;aAAM;YACN,MAAM;SACN;KACD;IACD,IAAI,IAAI,EAAE;QACT,GAAG,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;KAChC;IACD,OAAO,GAAG,CAAC,OAAO,EAAE,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC/C,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,eAAe,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5G,OAAO,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AACxB,CAAC","sourcesContent":["\n/**\n * a normal attribute with its source value without any binding.\n */\nexport class Attribute<N, V> {\n\tconstructor(public name: N, public value: V) { }\n}\n\nexport class ElementAttribute<N, V> extends Attribute<N, V> { }\n\n/**\n * an attribute with its source value for binding\n */\nexport class LiveAttribute extends Attribute<string, string> { }\n\n/**\n * \n * @param name \n * @param value \n * @returns LiveAttribute\n */\nexport function createLiveAttribute(name: string, value: string) {\n\treturn new LiveAttribute(name, value);\n}\n\n/**\n * a normal text\n */\nexport class TextContent extends Attribute<'textContent', string> {\n\tstatic propName: 'textContent' = 'textContent';\n\tconstructor(text: string) {\n\t\tsuper(TextContent.propName, text);\n\t}\n}\n\n/**\n * a text that its content is binding to variable from the component model.\n */\nexport class LiveTextContent extends TextContent { }\n\nexport function isLiveTextContent(text: object): text is LiveTextContent {\n\treturn text instanceof LiveTextContent;\n}\n\n/**\n * to comment in dom\n */\nexport class CommentNode {\n\tconstructor(public comment: string) { }\n}\n\n\nexport class BaseNode {\n\n\t/**\n\t * hold static attr and event that will resolve normally from the global window.\n\t */\n\tattributes?: ElementAttribute<string, string | number | boolean | object>[];\n\n\t/**\n\t * hold the attrs/inputs name marked as one way binding\n\t */\n\tinputs?: LiveAttribute[];\n\n\t/**\n\t * hold the name of events that should be connected to a listener\n\t */\n\toutputs?: ElementAttribute<string, string>[];\n\n\t/**\n\t * hold the name of attributes marked for 2 way data binding\n\t */\n\ttwoWayBinding?: LiveAttribute[];\n\n\t/**\n\t * directive attribute\n\t */\n\ttemplateAttrs?: LiveAttribute[];\n\n\t/**\n\t * attributes directive\n\t */\n\tattributeDirectives?: DomAttributeDirectiveNode[];\n\n\taddAttribute(attrName: string, value?: string | number | boolean | object) {\n\t\tif (this.attributes) {\n\t\t\tthis.attributes.push(new ElementAttribute(attrName, value ?? true));\n\t\t} else {\n\t\t\tthis.attributes = [new ElementAttribute(attrName, value ?? true)];\n\t\t}\n\t}\n\n\taddInput(attrName: string, valueSource: string) {\n\t\tif (this.inputs) {\n\t\t\tthis.inputs.push(new LiveAttribute(attrName, valueSource));\n\t\t} else {\n\t\t\tthis.inputs = [new LiveAttribute(attrName, valueSource)];\n\t\t}\n\t}\n\n\taddOutput(eventName: string, handlerSource: string) {\n\t\tif (this.outputs) {\n\t\t\tthis.outputs.push(new LiveAttribute(eventName, handlerSource));\n\t\t} else {\n\t\t\tthis.outputs = [new LiveAttribute(eventName, handlerSource)];\n\t\t}\n\t}\n\n\taddTwoWayBinding(eventName: string, handlerSource: string) {\n\t\tif (this.twoWayBinding) {\n\t\t\tthis.twoWayBinding.push(new LiveAttribute(eventName, handlerSource));\n\t\t} else {\n\t\t\tthis.twoWayBinding = [new LiveAttribute(eventName, handlerSource)];\n\t\t}\n\t}\n\n\taddTemplateAttr(attrName: string, valueSource: string) {\n\t\tvalueSource = valueSource.trim();\n\t\tif (/^\\{\\{(.+)\\}\\}$/g.test(valueSource)) {\n\t\t\t// as one way binding\n\t\t\tconst substring = valueSource.substring(2, valueSource.length - 2);\n\t\t\tif (!(/\\{\\{(.+)\\}\\}/g).test(substring)) {\n\t\t\t\tthis.addInput(attrName, substring);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\t// as string \n\t\tvalueSource = parseStringTemplate(valueSource);\n\t\tif (this.templateAttrs) {\n\t\t\tthis.templateAttrs.push(new LiveAttribute(attrName, valueSource));\n\t\t} else {\n\t\t\tthis.templateAttrs = [new LiveAttribute(attrName, valueSource)];\n\t\t}\n\t}\n\n}\nexport class DomAttributeDirectiveNode extends BaseNode {\n\n\t/**\n\t * name of the directive \n\t */\n\tname: string;\n\n\n\t/**\n\t * set to `undefined` stop, loop\n\t */\n\tattributeDirectives: undefined;\n\n\tconstructor(name: string) {\n\t\tsuper();\n\t\tthis.name = name;\n\t}\n}\n\nexport class DomParentNode extends BaseNode {\n\t/**\n\t * element children list\n\t */\n\tchildren?: DomChild[];\n\n\taddChild(child: DomChild) {\n\t\tif (this.children) {\n\t\t\tthis.children.push(child);\n\t\t} else {\n\t\t\tthis.children = [child];\n\t\t}\n\t}\n\n\taddTextChild(text: string) {\n\t\tconst children = (this.children ??= []);\n\t\tparseTextChild(text).forEach(childText => children.push(childText));\n\t}\n\n}\n\n/**\n * parent for a list of elements \n */\nexport class DomFragmentNode extends DomParentNode {\n\tconstructor(children?: DomChild[]) {\n\t\tsuper();\n\t\tif (children) {\n\t\t\tthis.children = children;\n\t\t}\n\t}\n}\nexport class DomElementNode extends DomParentNode {\n\n\t/**\n\t * the tag name of the element \n\t */\n\ttagName: string;\n\n\t/**\n\t * used to upgrade an element to another custom-element name\n\t */\n\tis?: string;\n\n\t/**\n\t * a given name for element\n\t */\n\ttemplateRefName?: Attribute<string, string | undefined>;\n\n\tconstructor(tagName: string, is?: string) {\n\t\tsuper();\n\t\tthis.tagName = tagName;\n\t\tif (is) {\n\t\t\tthis.is = is;\n\t\t}\n\t}\n\n\tsetTagName(tagName: string) {\n\t\tthis.tagName = tagName;\n\t}\n\n\tsetTemplateRefName(name: string, value?: string) {\n\t\tthis.templateRefName = new Attribute(name, value);\n\t}\n\n}\n\n/**\n * structural directive \n */\nexport class DomStructuralDirectiveNode extends BaseNode {\n\n\t/**\n\t * name of the directive \n\t */\n\tname: string;\n\n\t/**\n\t * value of the directive \n\t */\n\tvalue?: string;\n\n\t/**\n\t * the value of the template node, that this directive going to host-on \n\t */\n\tnode: DomNode;\n\n\tconstructor(name: string, node: DomNode, value?: string) {\n\t\tsuper();\n\t\tthis.name = name;\n\t\tthis.node = node;\n\t\tthis.value = value;\n\t}\n}\n\nexport function isDOMDirectiveNode(node: object): node is DomStructuralDirectiveNode {\n\treturn node instanceof DomStructuralDirectiveNode;\n}\nexport type DomChild = DomElementNode | DomStructuralDirectiveNode | CommentNode | TextContent | LiveTextContent;\n\nexport type DomNode = DomFragmentNode | DomElementNode | DomStructuralDirectiveNode | CommentNode | TextContent | LiveTextContent;\n\nexport type DomRenderNode<T> = (model: T) => DomNode;\n\nexport function parseTextChild(text: string): Array<TextContent | LiveTextContent> {\n\t// split from end with '}}', then search for the first '{{'\n\tlet all: (TextContent | LiveTextContent)[] = [];\n\tlet temp = text;\n\tlet last = temp.lastIndexOf('}}');\n\tlet first: number;\n\twhile (last > -1) {\n\t\tfirst = text.lastIndexOf('{{', last);\n\t\tif (first > -1) {\n\t\t\tlet lastPart = temp.substring(last + 2);\n\t\t\tif (lastPart) {\n\t\t\t\tall.push(new TextContent(lastPart));\n\t\t\t}\n\t\t\tconst liveText = new LiveTextContent(temp.substring(first + 2, last));\n\t\t\tall.push(liveText);\n\t\t\ttemp = temp.substring(0, first);\n\t\t\tlast = temp.lastIndexOf('}}');\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (temp) {\n\t\tall.push(new TextContent(temp));\n\t}\n\treturn all.reverse();\n}\n\nexport function parseStringTemplate(text: string): string {\n\tconst node = parseTextChild(text);\n\tconst map = node.map(str => (str instanceof LiveTextContent ? '${' + str.value + '}' : str.value)).join('');\n\treturn '`' + map + '`';\n}\n"]}
package/ast/factory.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DOMElementNode, DOMDirectiveNode, DOMChild, BaseNode, DOMFragmentNode, DOMNode } from './dom.js';
1
+ import { DomElementNode, DomStructuralDirectiveNode, DomChild, BaseNode, DomFragmentNode, DomNode, DomAttributeDirectiveNode } from './dom.js';
2
2
  export interface NodeAttr {
3
3
  [attr: string]: string;
4
4
  }
@@ -6,10 +6,11 @@ export declare class NodeFactory {
6
6
  static Fragment: string;
7
7
  static CommentTag: string;
8
8
  static DirectiveTag: string;
9
- static createElement(tagName: string, attrs?: NodeAttr, ...children: (string | DOMChild)[]): DOMNode;
10
- static createElementNode(tagName: string, attrs?: NodeAttr, ...children: (string | DOMChild)[]): DOMElementNode;
11
- static createFragmentNode(...children: (string | DOMChild)[]): DOMFragmentNode;
12
- static createDirectiveNode(directiveName: string, directiveValue: string, attrs?: NodeAttr, ...children: (string | DOMChild)[]): DOMDirectiveNode;
9
+ static createElement(tagName: string, attrs?: NodeAttr, ...children: (string | DomChild)[]): DomNode;
10
+ static createElementNode(tagName: string, attrs?: NodeAttr, ...children: (string | DomChild)[]): DomElementNode;
11
+ static createFragmentNode(...children: (string | DomChild)[]): DomFragmentNode;
12
+ static createStructuralDirectiveNode(directiveName: string, directiveValue: string, attrs?: NodeAttr, ...children: (string | DomChild)[]): DomStructuralDirectiveNode;
13
+ static createAttributeDirectiveNode(directiveName: string, attrs?: NodeAttr): DomAttributeDirectiveNode;
13
14
  static initElementAttrs(element: BaseNode, attrs?: NodeAttr): void;
14
15
  static handelAttribute(element: BaseNode, attrName: string, value: string | Function | object): void;
15
16
  }
package/ast/factory.js CHANGED
@@ -1,4 +1,4 @@
1
- import { DOMElementNode, DOMDirectiveNode, DOMFragmentNode, parseTextChild } from './dom.js';
1
+ import { DomElementNode, DomStructuralDirectiveNode, DomFragmentNode, parseTextChild, DomAttributeDirectiveNode } from './dom.js';
2
2
  import { directiveRegistry } from '../directives/register-directive.js';
3
3
  export class NodeFactory {
4
4
  static createElement(tagName, attrs, ...children) {
@@ -6,7 +6,7 @@ export class NodeFactory {
6
6
  return NodeFactory.createFragmentNode(...children);
7
7
  }
8
8
  if (directiveRegistry.has(tagName)) {
9
- return NodeFactory.createDirectiveNode(tagName, '', attrs, ...children);
9
+ return NodeFactory.createStructuralDirectiveNode(tagName, '', attrs, ...children);
10
10
  }
11
11
  if (NodeFactory.DirectiveTag === tagName.toLocaleLowerCase() && attrs) {
12
12
  if (attrs) {
@@ -15,9 +15,9 @@ export class NodeFactory {
15
15
  if (directiveName) {
16
16
  directiveValue = attrs[directiveName];
17
17
  delete attrs.directiveName;
18
- return NodeFactory.createDirectiveNode(directiveName, directiveValue, attrs, ...children);
18
+ return NodeFactory.createStructuralDirectiveNode(directiveName, directiveValue, attrs, ...children);
19
19
  }
20
- let node = new DOMElementNode(tagName, attrs?.is);
20
+ let node = new DomElementNode(tagName, attrs?.is);
21
21
  NodeFactory.initElementAttrs(node, attrs);
22
22
  children?.forEach(child => {
23
23
  if (typeof child === 'string') {
@@ -39,7 +39,7 @@ export class NodeFactory {
39
39
  let directiveName = attrKeys.find(attrName => attrName.startsWith('*'));
40
40
  if (directiveName) {
41
41
  let directiveValue = attrs[directiveName];
42
- return NodeFactory.createDirectiveNode(directiveName, directiveValue, attrs, node);
42
+ return NodeFactory.createStructuralDirectiveNode(directiveName, directiveValue, attrs, node);
43
43
  }
44
44
  return node;
45
45
  }
@@ -48,7 +48,7 @@ export class NodeFactory {
48
48
  }
49
49
  }
50
50
  static createElementNode(tagName, attrs, ...children) {
51
- let node = new DOMElementNode(tagName, attrs?.is);
51
+ let node = new DomElementNode(tagName, attrs?.is);
52
52
  NodeFactory.initElementAttrs(node, attrs);
53
53
  children?.forEach(child => {
54
54
  if (typeof child === 'string') {
@@ -69,13 +69,18 @@ export class NodeFactory {
69
69
  return [child];
70
70
  }
71
71
  });
72
- return new DOMFragmentNode(childStack);
72
+ return new DomFragmentNode(childStack);
73
73
  }
74
- static createDirectiveNode(directiveName, directiveValue, attrs, ...children) {
75
- const fragment = new DOMFragmentNode();
74
+ static createStructuralDirectiveNode(directiveName, directiveValue, attrs, ...children) {
75
+ const fragment = new DomFragmentNode();
76
76
  children?.forEach(child => (typeof child === 'string') ? fragment.addTextChild(child) : fragment.addChild(child));
77
77
  !directiveName.startsWith('*') && (directiveName = '*' + directiveName);
78
- const directive = new DOMDirectiveNode(directiveName, directiveValue ?? '', fragment);
78
+ const directive = new DomStructuralDirectiveNode(directiveName, fragment, directiveValue);
79
+ attrs && Object.keys(attrs).forEach(attr => directive.addAttribute(attr, attrs[attr]));
80
+ return directive;
81
+ }
82
+ static createAttributeDirectiveNode(directiveName, attrs) {
83
+ const directive = new DomAttributeDirectiveNode(directiveName);
79
84
  attrs && Object.keys(attrs).forEach(attr => directive.addAttribute(attr, attrs[attr]));
80
85
  return directive;
81
86
  }
@@ -84,14 +89,32 @@ export class NodeFactory {
84
89
  Object.keys(attrs).forEach(key => {
85
90
  NodeFactory.handelAttribute(element, key, attrs[key]);
86
91
  });
92
+ const directives = [];
93
+ Object.keys(attrs).forEach(attributeName => {
94
+ if (directiveRegistry.has(attributeName)) {
95
+ Reflect.deleteProperty(attrs, attributeName);
96
+ const directive = new DomAttributeDirectiveNode(attributeName);
97
+ const directiveInfo = directiveRegistry.get(attributeName);
98
+ Object.keys(attrs).forEach(attr => {
99
+ if (directiveInfo.hasAttribute(attr)) {
100
+ directive.addAttribute(attr, attrs[attr]);
101
+ Reflect.deleteProperty(attrs, attr);
102
+ }
103
+ });
104
+ directives.push(directive);
105
+ }
106
+ });
107
+ if (directives.length) {
108
+ element.attributeDirectives = directives;
109
+ }
87
110
  }
88
111
  }
89
112
  static handelAttribute(element, attrName, value) {
90
- if (attrName.startsWith('#') && element instanceof DOMElementNode) {
113
+ if (attrName.startsWith('#') && element instanceof DomElementNode) {
91
114
  attrName = attrName.substring(1);
92
115
  element.setTemplateRefName(attrName, value);
93
116
  }
94
- else if (attrName === 'is' && element instanceof DOMElementNode) {
117
+ else if (attrName === 'is' && element instanceof DomElementNode) {
95
118
  element.is = value;
96
119
  return;
97
120
  }
@@ -1 +1 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/elements/ast/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EAAE,gBAAgB,EACtB,eAAe,EAAE,cAAc,EACzC,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAMxE,MAAM,OAAO,WAAW;IAQvB,MAAM,CAAC,aAAa,CAAC,OAAe,EAAE,KAAgB,EAAE,GAAG,QAA+B;QAEzF,IAAI,WAAW,CAAC,QAAQ,KAAK,OAAO,CAAC,WAAW,EAAE,EAAE;YACnD,OAAO,WAAW,CAAC,kBAAkB,CAAC,GAAG,QAAQ,CAAC,CAAC;SACnD;QAOD,IAAI,iBAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;YACnC,OAAO,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAC;SACxE;QAID,IAAI,WAAW,CAAC,YAAY,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Y,GAAG,WAAW,CAAC","sourcesContent":["import {\n\tDOMElementNode, DOMDirectiveNode, DOMChild,\n\tBaseNode, DOMFragmentNode, parseTextChild, DOMNode\n} from './dom.js';\nimport { directiveRegistry } from '../directives/register-directive.js';\n\nexport interface NodeAttr {\n\t[attr: string]: string;\n}\n\nexport class NodeFactory {\n\n\tstatic Fragment = 'fragment';\n\n\tstatic CommentTag = 'comment';\n\n\tstatic DirectiveTag = 'directive';\n\n\tstatic createElement(tagName: string, attrs?: NodeAttr, ...children: (string | DOMChild)[]): DOMNode {\n\n\t\tif (NodeFactory.Fragment === tagName.toLowerCase()) {\n\t\t\treturn NodeFactory.createFragmentNode(...children);\n\t\t}\n\t\t/**\n\t\t * structural directive -- jsx support\n\t\t * \n\t\t * <if condition=\"element.show\"> {'{{element.name}}'} </if>\n\t\t * <div _if=\"element.show\">{'{{element.name}}'} </div>\n\t\t */\n\t\tif (directiveRegistry.has(tagName)) {\n\t\t\treturn NodeFactory.createDirectiveNode(tagName, '', attrs, ...children);\n\t\t}\n\t\t/**\n\t\t * <directive *if=\"element.show\" >{'{{element.name}}'}</directive>\n\t\t */\n\t\tif (NodeFactory.DirectiveTag === tagName.toLocaleLowerCase() && attrs) {\n\t\t\tif (attrs) {\n\t\t\t\tlet directiveName = Object.keys(attrs).find(attrName => attrName.startsWith('*'));\n\t\t\t\tlet directiveValue: string;\n\n\t\t\t\tif (directiveName) {\n\t\t\t\t\t// is directive\n\t\t\t\t\tdirectiveValue = attrs[directiveName];\n\t\t\t\t\tdelete attrs.directiveName;\n\t\t\t\t\treturn NodeFactory.createDirectiveNode(directiveName, directiveValue, attrs, ...children);\n\t\t\t\t}\n\t\t\t\tlet node = new DOMElementNode(tagName, attrs?.is);\n\t\t\t\tNodeFactory.initElementAttrs(node, attrs);\n\t\t\t\tchildren?.forEach(child => {\n\t\t\t\t\tif (typeof child === 'string') {\n\t\t\t\t\t\tnode.addTextChild(child)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnode.addChild(child);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn node;\n\t\t\t} else {\n\t\t\t\t// return new CommentNode('empty directive');\n\t\t\t\treturn NodeFactory.createFragmentNode(...children);\n\t\t\t}\n\t\t}\n\t\t// let node: ElementNode | DirectiveNode = new ElementNode(tagName, attrs?.is);\n\t\tif (attrs) {\n\t\t\tlet node = NodeFactory.createElementNode(tagName, attrs, ...children);\n\t\t\tconst attrKeys = Object.keys(attrs);\n\t\t\tlet directiveName = attrKeys.find(attrName => attrName.startsWith('*'));\n\t\t\tif (directiveName) {\n\t\t\t\tlet directiveValue = attrs[directiveName];\n\t\t\t\treturn NodeFactory.createDirectiveNode(directiveName, directiveValue, attrs, node);\n\t\t\t}\n\t\t\treturn node;\n\t\t} else {\n\t\t\treturn NodeFactory.createElementNode(tagName, attrs, ...children);\n\t\t}\n\t}\n\n\tstatic createElementNode(tagName: string, attrs?: NodeAttr, ...children: (string | DOMChild)[]) {\n\t\tlet node = new DOMElementNode(tagName, attrs?.is);\n\t\tNodeFactory.initElementAttrs(node, attrs);\n\t\tchildren?.forEach(child => {\n\t\t\tif (typeof child === 'string') {\n\t\t\t\tnode.addTextChild(child)\n\t\t\t} else {\n\t\t\t\tnode.addChild(child);\n\t\t\t}\n\t\t});\n\t\treturn node;\n\t}\n\n\tstatic createFragmentNode(...children: (string | DOMChild)[]) {\n\t\tlet childStack = children.flatMap(child => {\n\t\t\tif (typeof child === 'string') {\n\t\t\t\treturn parseTextChild(child);\n\t\t\t} else {\n\t\t\t\treturn [child];\n\t\t\t}\n\t\t});\n\t\treturn new DOMFragmentNode(childStack);\n\t}\n\n\tstatic createDirectiveNode(directiveName: string, directiveValue: string, attrs?: NodeAttr, ...children: (string | DOMChild)[]) {\n\t\tconst fragment = new DOMFragmentNode();\n\t\tchildren?.forEach(child => (typeof child === 'string') ? fragment.addTextChild(child) : fragment.addChild(child));\n\t\t!directiveName.startsWith('*') && (directiveName = '*' + directiveName);\n\t\tconst directive = new DOMDirectiveNode(directiveName, directiveValue ?? '', fragment);\n\t\tattrs && Object.keys(attrs).forEach(attr => directive.addAttribute(attr, attrs[attr]));\n\t\treturn directive;\n\t}\n\n\tstatic initElementAttrs(element: BaseNode, attrs?: NodeAttr) {\n\t\tif (attrs) {\n\t\t\tObject.keys(attrs).forEach(key => {\n\t\t\t\tNodeFactory.handelAttribute(element, key, attrs[key]);\n\t\t\t});\n\t\t}\n\t}\n\n\tstatic handelAttribute(element: BaseNode, attrName: string, value: string | Function | object): void {\n\n\t\tif (attrName.startsWith('#') && element instanceof DOMElementNode) {\n\t\t\t// <app-tag #element-name=\"directiveName?\" ></app-tag>\n\t\t\tattrName = attrName.substring(1);\n\t\t\telement.setTemplateRefName(attrName, value as string);\n\t\t}\n\t\telse if (attrName === 'is' && element instanceof DOMElementNode) {\n\t\t\telement.is = value as string;\n\t\t\treturn;\n\t\t}\n\t\telse if (attrName.startsWith('[(')) {\n\t\t\t// [(attr)]=\"modelProperty\"\n\t\t\tattrName = attrName.substring(2, attrName.length - 2);\n\t\t\telement.addTwoWayBinding(attrName, value as string);\n\t\t}\n\t\telse if (attrName.startsWith('$') && typeof value === 'string' && value.startsWith('$')) {\n\t\t\t// $attr=\"$viewProperty\" \n\t\t\tattrName = attrName.substring(1);\n\t\t\tvalue = value.substring(1);\n\t\t\telement.addTwoWayBinding(attrName, value as string);\n\t\t}\n\t\telse if (attrName.startsWith('[')) {\n\t\t\t// [attr]=\"modelProperty\"\n\t\t\tattrName = attrName.substring(1, attrName.length - 1);\n\t\t\telement.addInput(attrName, value as string);\n\t\t}\n\t\telse if (attrName.startsWith('$') && typeof value === 'string') {\n\t\t\t// $attr=\"viewProperty\" \n\t\t\tattrName = attrName.substring(1);\n\t\t\telement.addInput(attrName, value as string);\n\t\t}\n\t\telse if (attrName.startsWith('$') && typeof value === 'object') {\n\t\t\t// $attr={viewProperty} // as an object\n\t\t\tattrName = attrName.substring(1);\n\t\t\telement.addAttribute(attrName, value);\n\t\t}\n\t\telse if (typeof value === 'string' && value.startsWith('$')) {\n\t\t\t// bad practice\n\t\t\t// attr=\"$viewProperty\" // as an object\n\n\t\t\t// value = value.substring(1);\n\t\t\t// element.addAttribute(attrName, value);\n\t\t\treturn;\n\t\t}\n\t\telse if (typeof value === 'string' && (/^\\{\\{(.+\\w*)*\\}\\}/g).test(value)) {\n\t\t\t// attr=\"{{viewProperty}}\" // just pass data\n\t\t\tvalue = value.substring(2, value.length - 2);\n\t\t\telement.addInput(attrName, value);\n\t\t}\n\t\telse if (typeof value === 'string' && (/\\{\\{(.+)\\}\\}/g).test(value)) {\n\t\t\t// attr=\"any string{{viewProperty}}any text\" // just pass data\n\t\t\telement.addTemplateAttr(attrName, value);\n\t\t}\n\t\telse if (attrName.startsWith('(')) {\n\t\t\t// (elementAttr)=\"modelProperty()\"\n\t\t\tattrName = attrName.substring(1, attrName.length - 1);\n\t\t\telement.addOutput(attrName, value as string);\n\t\t}\n\t\telse if (attrName.startsWith('on')) {\n\t\t\t// onAttr=\"modelProperty()\"\n\t\t\t// onAttr={modelProperty} // as an function\n\t\t\telement.addOutput(attrName.substring(2), value as string);\n\t\t}\n\t\telse {\n\t\t\telement.addAttribute(attrName, value);\n\t\t}\n\t}\n\n}\n"]}
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../src/elements/ast/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EAAE,0BAA0B,EAChC,eAAe,EAAE,cAAc,EACzC,yBAAyB,EACzB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAMxE,MAAM,OAAO,WAAW;IAQvB,MAAM,CAAC,aAAa,CAAC,OAAe,EAAE,KAAgB,EAAE,GAAG,QAA+B;QAEzF,IAAI,WAAW,CAAC,QAAQ,KAAK,OAAO,CAAC,WAAW,EAAE,EAAE;YACnD,OAAO,WAAW,CAAC,kBAAkB,CAAC,GAAG,QAAQ,CAAC,CAAC;SACnD;Q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EAAE,KAAK,CAAC,CAAC;SACtC;IACF,CAAC;;AArMM,oBAAQ,GAAG,UAAU,CAAC;AAEtB,sBAAU,GAAG,SAAS,CAAC;AAEvB,wBAAY,GAAG,WAAW,CAAC","sourcesContent":["import {\n\tDomElementNode, DomStructuralDirectiveNode, DomChild,\n\tBaseNode, DomFragmentNode, parseTextChild, DomNode,\n\tDomAttributeDirectiveNode\n} from './dom.js';\nimport { directiveRegistry } from '../directives/register-directive.js';\n\nexport interface NodeAttr {\n\t[attr: string]: string;\n}\n\nexport class NodeFactory {\n\n\tstatic Fragment = 'fragment';\n\n\tstatic CommentTag = 'comment';\n\n\tstatic DirectiveTag = 'directive';\n\n\tstatic createElement(tagName: string, attrs?: NodeAttr, ...children: (string | DomChild)[]): DomNode {\n\n\t\tif (NodeFactory.Fragment === tagName.toLowerCase()) {\n\t\t\treturn NodeFactory.createFragmentNode(...children);\n\t\t}\n\t\t/**\n\t\t * structural directive -- jsx support\n\t\t * \n\t\t * <if condition=\"element.show\"> {'{{element.name}}'} </if>\n\t\t * <div _if=\"element.show\">{'{{element.name}}'} </div>\n\t\t */\n\t\tif (directiveRegistry.has(tagName)) {\n\t\t\treturn NodeFactory.createStructuralDirectiveNode(tagName, '', attrs, ...children);\n\t\t}\n\t\t/**\n\t\t * <directive *if=\"element.show\" >{'{{element.name}}'}</directive>\n\t\t */\n\t\tif (NodeFactory.DirectiveTag === tagName.toLocaleLowerCase() && attrs) {\n\t\t\tif (attrs) {\n\t\t\t\tlet directiveName = Object.keys(attrs).find(attrName => attrName.startsWith('*'));\n\t\t\t\tlet directiveValue: string;\n\n\t\t\t\tif (directiveName) {\n\t\t\t\t\t// is directive\n\t\t\t\t\tdirectiveValue = attrs[directiveName];\n\t\t\t\t\tdelete attrs.directiveName;\n\t\t\t\t\treturn NodeFactory.createStructuralDirectiveNode(directiveName, directiveValue, attrs, ...children);\n\t\t\t\t}\n\t\t\t\tlet node = new DomElementNode(tagName, attrs?.is);\n\t\t\t\tNodeFactory.initElementAttrs(node, attrs);\n\t\t\t\tchildren?.forEach(child => {\n\t\t\t\t\tif (typeof child === 'string') {\n\t\t\t\t\t\tnode.addTextChild(child)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnode.addChild(child);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn node;\n\t\t\t} else {\n\t\t\t\t// return new CommentNode('empty directive');\n\t\t\t\treturn NodeFactory.createFragmentNode(...children);\n\t\t\t}\n\t\t}\n\t\t// let node: ElementNode | DirectiveNode = new ElementNode(tagName, attrs?.is);\n\t\tif (attrs) {\n\t\t\tlet node = NodeFactory.createElementNode(tagName, attrs, ...children);\n\t\t\tconst attrKeys = Object.keys(attrs);\n\t\t\tlet directiveName = attrKeys.find(attrName => attrName.startsWith('*'));\n\t\t\tif (directiveName) {\n\t\t\t\tlet directiveValue = attrs[directiveName];\n\t\t\t\treturn NodeFactory.createStructuralDirectiveNode(directiveName, directiveValue, attrs, node);\n\t\t\t}\n\t\t\treturn node;\n\t\t} else {\n\t\t\treturn NodeFactory.createElementNode(tagName, attrs, ...children);\n\t\t}\n\t}\n\n\tstatic createElementNode(tagName: string, attrs?: NodeAttr, ...children: (string | DomChild)[]) {\n\t\tlet node = new DomElementNode(tagName, attrs?.is);\n\t\tNodeFactory.initElementAttrs(node, attrs);\n\t\tchildren?.forEach(child => {\n\t\t\tif (typeof child === 'string') {\n\t\t\t\tnode.addTextChild(child)\n\t\t\t} else {\n\t\t\t\tnode.addChild(child);\n\t\t\t}\n\t\t});\n\t\treturn node;\n\t}\n\n\tstatic createFragmentNode(...children: (string | DomChild)[]) {\n\t\tlet childStack = children.flatMap(child => {\n\t\t\tif (typeof child === 'string') {\n\t\t\t\treturn parseTextChild(child);\n\t\t\t} else {\n\t\t\t\treturn [child];\n\t\t\t}\n\t\t});\n\t\treturn new DomFragmentNode(childStack);\n\t}\n\n\tstatic createStructuralDirectiveNode(directiveName: string, directiveValue: string, attrs?: NodeAttr, ...children: (string | DomChild)[]) {\n\t\tconst fragment = new DomFragmentNode();\n\t\tchildren?.forEach(child => (typeof child === 'string') ? fragment.addTextChild(child) : fragment.addChild(child));\n\t\t!directiveName.startsWith('*') && (directiveName = '*' + directiveName);\n\t\tconst directive = new DomStructuralDirectiveNode(directiveName, fragment, directiveValue);\n\t\tattrs && Object.keys(attrs).forEach(attr => directive.addAttribute(attr, attrs[attr]));\n\t\treturn directive;\n\t}\n\n\tstatic createAttributeDirectiveNode(directiveName: string, attrs?: NodeAttr) {\n\t\tconst directive = new DomAttributeDirectiveNode(directiveName);\n\t\tattrs && Object.keys(attrs).forEach(attr => directive.addAttribute(attr, attrs[attr]));\n\t\treturn directive;\n\t}\n\n\tstatic initElementAttrs(element: BaseNode, attrs?: NodeAttr) {\n\t\tif (attrs) {\n\t\t\tObject.keys(attrs).forEach(key => {\n\t\t\t\tNodeFactory.handelAttribute(element, key, attrs[key]);\n\t\t\t});\n\n\t\t\tconst directives: DomAttributeDirectiveNode[] = [];\n\t\t\tObject.keys(attrs).forEach(attributeName => {\n\t\t\t\tif (directiveRegistry.has(attributeName)) {\n\t\t\t\t\tReflect.deleteProperty(attrs, attributeName);\n\t\t\t\t\tconst directive = new DomAttributeDirectiveNode(attributeName);\n\t\t\t\t\tconst directiveInfo = directiveRegistry.get(attributeName)!;\n\t\t\t\t\tObject.keys(attrs).forEach(attr => {\n\t\t\t\t\t\tif (directiveInfo.hasAttribute(attr)) {\n\t\t\t\t\t\t\tdirective.addAttribute(attr, attrs[attr]);\n\t\t\t\t\t\t\tReflect.deleteProperty(attrs, attr);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tdirectives.push(directive);\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (directives.length) {\n\t\t\t\telement.attributeDirectives = directives;\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic handelAttribute(element: BaseNode, attrName: string, value: string | Function | object): void {\n\n\t\tif (attrName.startsWith('#') && element instanceof DomElementNode) {\n\t\t\t// <app-tag #element-name=\"directiveName?\" ></app-tag>\n\t\t\tattrName = attrName.substring(1);\n\t\t\telement.setTemplateRefName(attrName, value as string);\n\t\t}\n\t\telse if (attrName === 'is' && element instanceof DomElementNode) {\n\t\t\telement.is = value as string;\n\t\t\treturn;\n\t\t}\n\t\telse if (attrName.startsWith('[(')) {\n\t\t\t// [(attr)]=\"modelProperty\"\n\t\t\tattrName = attrName.substring(2, attrName.length - 2);\n\t\t\telement.addTwoWayBinding(attrName, value as string);\n\t\t}\n\t\telse if (attrName.startsWith('$') && typeof value === 'string' && value.startsWith('$')) {\n\t\t\t// $attr=\"$viewProperty\" \n\t\t\tattrName = attrName.substring(1);\n\t\t\tvalue = value.substring(1);\n\t\t\telement.addTwoWayBinding(attrName, value as string);\n\t\t}\n\t\telse if (attrName.startsWith('[')) {\n\t\t\t// [attr]=\"modelProperty\"\n\t\t\tattrName = attrName.substring(1, attrName.length - 1);\n\t\t\telement.addInput(attrName, value as string);\n\t\t}\n\t\telse if (attrName.startsWith('$') && typeof value === 'string') {\n\t\t\t// $attr=\"viewProperty\" \n\t\t\tattrName = attrName.substring(1);\n\t\t\telement.addInput(attrName, value as string);\n\t\t}\n\t\telse if (attrName.startsWith('$') && typeof value === 'object') {\n\t\t\t// $attr={viewProperty} // as an object\n\t\t\tattrName = attrName.substring(1);\n\t\t\telement.addAttribute(attrName, value);\n\t\t}\n\t\telse if (typeof value === 'string' && value.startsWith('$')) {\n\t\t\t// bad practice\n\t\t\t// attr=\"$viewProperty\" // as an object\n\n\t\t\t// value = value.substring(1);\n\t\t\t// element.addAttribute(attrName, value);\n\t\t\treturn;\n\t\t}\n\t\telse if (typeof value === 'string' && (/^\\{\\{(.+\\w*)*\\}\\}/g).test(value)) {\n\t\t\t// attr=\"{{viewProperty}}\" // just pass data\n\t\t\tvalue = value.substring(2, value.length - 2);\n\t\t\telement.addInput(attrName, value);\n\t\t}\n\t\telse if (typeof value === 'string' && (/\\{\\{(.+)\\}\\}/g).test(value)) {\n\t\t\t// attr=\"any string{{viewProperty}}any text\" // just pass data\n\t\t\telement.addTemplateAttr(attrName, value);\n\t\t}\n\t\telse if (attrName.startsWith('(')) {\n\t\t\t// (elementAttr)=\"modelProperty()\"\n\t\t\tattrName = attrName.substring(1, attrName.length - 1);\n\t\t\telement.addOutput(attrName, value as string);\n\t\t}\n\t\telse if (attrName.startsWith('on')) {\n\t\t\t// onAttr=\"modelProperty()\"\n\t\t\t// onAttr={modelProperty} // as an function\n\t\t\telement.addOutput(attrName.substring(2), value as string);\n\t\t}\n\t\telse {\n\t\t\telement.addAttribute(attrName, value);\n\t\t}\n\t}\n\n}\n"]}
@@ -5,3 +5,4 @@ export declare const GlobalAttributes: string[];
5
5
  export declare const Attrs: AttrRef;
6
6
  export declare function hasNativeAttr(element: string | HTMLElement, attr: string): boolean;
7
7
  export declare function getTagsForAttr(attr: string): string[];
8
+ export declare function getAllAttributes(tag?: string): string[];
@@ -153,4 +153,10 @@ export function hasNativeAttr(element, attr) {
153
153
  export function getTagsForAttr(attr) {
154
154
  return Object.keys(Attrs).filter(tag => Attrs[tag].includes(attr));
155
155
  }
156
+ export function getAllAttributes(tag) {
157
+ if (tag) {
158
+ return Attrs[tag];
159
+ }
160
+ return GlobalAttributes.slice();
161
+ }
156
162
  //# sourceMappingURL=attributes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../../src/elements/attributes/attributes.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,OAAO;IACP,IAAI;IACJ,MAAM;IACN,WAAW;IACX,gBAAgB;IAChB,WAAW;IACX,iBAAiB;IACjB,KAAK;IACL,WAAW;IACX,cAAc;IACd,QAAQ;IACR,WAAW;IACX,IAAI;IACJ,QAAQ;IACR,UAAU;IACV,SAAS;IACT,WAAW;IACX,UAAU;IACV,MAAM;IACN,OAAO;IACP,YAAY;IACZ,OAAO;IACP,UAAU;IACV,OAAO;IACP,WAAW;CACX,CAAC;AA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**\n * @see https://html.spec.whatwg.org/multipage/indices.html#elements-3\n */\nexport const GlobalAttributes = [\n\t'class',\n\t'id',\n\t'slot',\n\t'accesskey',\n\t'autocapitalize',\n\t'autofocus',\n\t'contenteditable',\n\t'dir',\n\t'draggable',\n\t'enterkeyhint',\n\t'hidden',\n\t'inputmode',\n\t'is',\n\t'itemid',\n\t'itemprop',\n\t'itemref',\n\t'itemscope',\n\t'itemtype',\n\t'lang',\n\t'nonce',\n\t'spellcheck',\n\t'style',\n\t'tabindex',\n\t'title',\n\t'translate'\n];\n\nexport const Attrs: AttrRef = {\n\ta: [...GlobalAttributes, 'href', 'target', 'download', 'ping', 'rel', 'hreflang', 'type', 'referrerpolicy'],\n\tabbr: GlobalAttributes,\n\taddress: GlobalAttributes,\n\tarea: [...GlobalAttributes, 'alt', 'coords', 'shape', 'href', 'target', 'download', 'ping', 'rel', 'referrerpolicy'],\n\tarticle: GlobalAttributes,\n\taside: GlobalAttributes,\n\taudio: [...GlobalAttributes, 'src', 'crossorigin', 'preload', 'autoplay', 'loop', 'muted', 'controls'],\n\tb: GlobalAttributes,\n\tbase: [...GlobalAttributes, 'href', 'targetreferrerpolicy'],\n\tbdi: GlobalAttributes,\n\tbdo: GlobalAttributes,\n\tblockquote: [...GlobalAttributes, 'cite'],\n\tbody: [...GlobalAttributes, 'onafterprint; onbeforeprint; onbeforeunload; onhashchange; onlanguagechange; onmessage; onmessageerror; onoffline; ononline; onpagehide; onpageshow; onpopstate; onrejectionhandled; onstorage; onunhandledrejection; onunload'],\n\tbr: GlobalAttributes,\n\tbutton: [...GlobalAttributes, 'disabled', 'form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'name', 'type', 'value'],\n\tcanvas: [...GlobalAttributes, 'width', 'height'],\n\tcaption: GlobalAttributes,\n\tcite: GlobalAttributes,\n\tcode: GlobalAttributes,\n\tcol: [...GlobalAttributes, 'span'],\n\tcolgroup: [...GlobalAttributes, 'span'],\n\tdata: [...GlobalAttributes, 'value'],\n\tdatalist: GlobalAttributes,\n\tdd: GlobalAttributes,\n\tdel: [...GlobalAttributes, 'cite', 'datetime'],\n\tdetails: [...GlobalAttributes, 'open'],\n\tdfn: GlobalAttributes,\n\tdialog: [...GlobalAttributes, 'open'],\n\tdiv: GlobalAttributes,\n\tdl: GlobalAttributes,\n\tdt: GlobalAttributes,\n\tem: GlobalAttributes,\n\tembed: [...GlobalAttributes, 'src', 'type', 'width', 'height', 'any*'],\n\tfieldset: [...GlobalAttributes, 'disabled', 'form', 'name'],\n\tfigcaption: GlobalAttributes,\n\tfigure: GlobalAttributes,\n\tfooter: GlobalAttributes,\n\tform: [...GlobalAttributes, 'accept-charset', 'action', 'autocomplete', 'enctype', 'method', 'name', 'novalidate', 'target'],\n\th1: GlobalAttributes,\n\th2: GlobalAttributes,\n\th3: GlobalAttributes,\n\th4: GlobalAttributes,\n\th5: GlobalAttributes,\n\th6: GlobalAttributes,\n\thead: GlobalAttributes,\n\theader: GlobalAttributes,\n\thgroup: GlobalAttributes,\n\thr: GlobalAttributes,\n\thtml: [...GlobalAttributes, 'manifest'],\n\ti: GlobalAttributes,\n\tiframe: [...GlobalAttributes, 'src', 'srcdoc', 'name', 'sandbox', 'allow', 'allowfullscreen', 'allowpaymentrequest', 'width', 'height', 'referrerpolicy', 'loading'],\n\timg: [...GlobalAttributes, 'alt', 'src', 'srcset', 'sizes', 'crossorigin', 'usemap', 'ismap', 'width', 'height', 'referrerpolicy', 'decoding', 'loading'],\n\tinput: [...GlobalAttributes, 'accept', 'alt', 'autocomplete', 'checked', 'dirname', 'disabled', 'form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'height', 'list', 'max', 'maxlength', 'min', 'minlength', 'multiple', 'name', 'pattern', 'placeholder', 'readonly', 'required', 'size', 'src', 'step', 'type', 'value', 'width'],\n\tins: [...GlobalAttributes, 'cite', 'datetime'],\n\tkbd: GlobalAttributes,\n\tlabel: [...GlobalAttributes, 'for'],\n\tlegend: GlobalAttributes,\n\tli: [...GlobalAttributes, 'value'],\n\tlink: [...GlobalAttributes, 'href', 'crossorigin', 'rel', 'as', 'media', 'hreflang', 'type', 'sizes', 'imagesrcset', 'imagesizes', 'referrerpolicy', 'integrity', 'color', 'disabled'],\n\tmain: GlobalAttributes,\n\tmap: [...GlobalAttributes, 'name'],\n\tmark: GlobalAttributes,\n\tmenu: GlobalAttributes,\n\tmeta: [...GlobalAttributes, 'name', 'http-equiv', 'content', 'charset'],\n\tmeter: [...GlobalAttributes, 'value', 'min', 'max', 'low', 'high', 'optimum'],\n\tnav: GlobalAttributes,\n\tnoscript: GlobalAttributes,\n\tobject: [...GlobalAttributes, 'data', 'type', 'name', 'usemap', 'form', 'width', 'height'],\n\tol: [...GlobalAttributes, 'reversed', 'start', 'type'],\n\toptgroup: [...GlobalAttributes, 'disabled', 'label'],\n\toption: [...GlobalAttributes, 'disabled', 'label', 'selected', 'value'],\n\toutput: [...GlobalAttributes, 'for', 'form', 'name'],\n\tp: GlobalAttributes,\n\tparam: [...GlobalAttributes, 'name', 'value'],\n\tpicture: GlobalAttributes,\n\tpre: GlobalAttributes,\n\tprogress: [...GlobalAttributes, 'value', 'max'],\n\tq: [...GlobalAttributes, 'cite'],\n\trp: GlobalAttributes,\n\trt: GlobalAttributes,\n\truby: GlobalAttributes,\n\ts: GlobalAttributes,\n\tsamp: GlobalAttributes,\n\tscript: [...GlobalAttributes, 'src', 'type', 'async', 'defer', 'crossorigin', 'integrity', 'referrerpolicy'],\n\tsection: GlobalAttributes,\n\tselect: [...GlobalAttributes, 'autocomplete', 'disabled', 'form', 'multiple', 'name', 'required', 'size'],\n\tslot: [...GlobalAttributes, 'name'],\n\tsmall: GlobalAttributes,\n\tsource: [...GlobalAttributes, 'src', 'type', 'srcset', 'sizes', 'media'],\n\tspan: GlobalAttributes,\n\tstrong: GlobalAttributes,\n\tstyle: [...GlobalAttributes, 'media'],\n\tsub: GlobalAttributes,\n\tsummary: GlobalAttributes,\n\tsup: GlobalAttributes,\n\ttable: GlobalAttributes,\n\ttbody: GlobalAttributes,\n\ttd: [...GlobalAttributes, 'colspan', 'rowspan', 'headers'],\n\ttemplate: GlobalAttributes,\n\ttextarea: [...GlobalAttributes, 'cols', 'dirname', 'disabled', 'form', 'maxlength', 'minlength', 'name', 'placeholder', 'readonly', 'required', 'rows', 'wrap'],\n\ttfoot: GlobalAttributes,\n\tth: [...GlobalAttributes, 'colspan', 'rowspan', 'headers', 'scope', 'abbr'],\n\tthead: GlobalAttributes,\n\ttime: [...GlobalAttributes, 'datetime'],\n\ttitle: GlobalAttributes,\n\ttr: GlobalAttributes,\n\ttrack: [...GlobalAttributes, 'default', 'kind', 'label', 'src', 'srclang'],\n\tu: GlobalAttributes,\n\tul: GlobalAttributes,\n\tvar: GlobalAttributes,\n\tvideo: [...GlobalAttributes, 'src', 'crossorigin', 'poster', 'preload', 'autoplay', 'playsinline', 'loop', 'muted', 'controls', 'width', 'height'],\n\twbr: GlobalAttributes,\n\t'virtual-scroller': GlobalAttributes\n};\n\n\nexport function hasNativeAttr(element: string | HTMLElement, attr: string): boolean {\n\tif (typeof element === 'string') {\n\t\treturn Attrs[element.toLowerCase()]?.includes(attr);\n\t} else if (element instanceof HTMLElement) {\n\t\tconst tagName = element.tagName.toLowerCase();\n\t\treturn Attrs[tagName]?.includes(attr);\n\t}\n\treturn false;\n}\n\nexport function getTagsForAttr(attr: string): string[] {\n\treturn Object.keys(Attrs).filter(tag => Attrs[tag].includes(attr));\n}\n"]}
1
+ {"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../../src/elements/attributes/attributes.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC/B,OAAO;IACP,IAAI;IACJ,MAAM;IACN,WAAW;IACX,gBAAgB;IAChB,WAAW;IACX,iBAAiB;IACjB,KAAK;IACL,WAAW;IACX,cAAc;IACd,QAAQ;IACR,WAAW;IACX,IAAI;IACJ,QAAQ;IACR,UAAU;IACV,SAAS;IACT,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AC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAY;IAC5C,IAAI,GAAG,EAAE;QACR,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;KAClB;IACD,OAAO,gBAAgB,CAAC,KAAK,EAAE,CAAC;AACjC,CAAC","sourcesContent":["import { DefaultTag } from './tags.js';\n\nexport interface AttrRef {\n\treadonly [attr: string]: string[];\n}\n\n/**\n * @see https://html.spec.whatwg.org/multipage/indices.html#elements-3\n */\nexport const GlobalAttributes = [\n\t'class',\n\t'id',\n\t'slot',\n\t'accesskey',\n\t'autocapitalize',\n\t'autofocus',\n\t'contenteditable',\n\t'dir',\n\t'draggable',\n\t'enterkeyhint',\n\t'hidden',\n\t'inputmode',\n\t'is',\n\t'itemid',\n\t'itemprop',\n\t'itemref',\n\t'itemscope',\n\t'itemtype',\n\t'lang',\n\t'nonce',\n\t'spellcheck',\n\t'style',\n\t'tabindex',\n\t'title',\n\t'translate'\n];\n\nexport const Attrs: AttrRef = {\n\ta: [...GlobalAttributes, 'href', 'target', 'download', 'ping', 'rel', 'hreflang', 'type', 'referrerpolicy'],\n\tabbr: GlobalAttributes,\n\taddress: GlobalAttributes,\n\tarea: [...GlobalAttributes, 'alt', 'coords', 'shape', 'href', 'target', 'download', 'ping', 'rel', 'referrerpolicy'],\n\tarticle: GlobalAttributes,\n\taside: GlobalAttributes,\n\taudio: [...GlobalAttributes, 'src', 'crossorigin', 'preload', 'autoplay', 'loop', 'muted', 'controls'],\n\tb: GlobalAttributes,\n\tbase: [...GlobalAttributes, 'href', 'targetreferrerpolicy'],\n\tbdi: GlobalAttributes,\n\tbdo: GlobalAttributes,\n\tblockquote: [...GlobalAttributes, 'cite'],\n\tbody: [...GlobalAttributes, 'onafterprint; onbeforeprint; onbeforeunload; onhashchange; onlanguagechange; onmessage; onmessageerror; onoffline; ononline; onpagehide; onpageshow; onpopstate; onrejectionhandled; onstorage; onunhandledrejection; onunload'],\n\tbr: GlobalAttributes,\n\tbutton: [...GlobalAttributes, 'disabled', 'form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'name', 'type', 'value'],\n\tcanvas: [...GlobalAttributes, 'width', 'height'],\n\tcaption: GlobalAttributes,\n\tcite: GlobalAttributes,\n\tcode: GlobalAttributes,\n\tcol: [...GlobalAttributes, 'span'],\n\tcolgroup: [...GlobalAttributes, 'span'],\n\tdata: [...GlobalAttributes, 'value'],\n\tdatalist: GlobalAttributes,\n\tdd: GlobalAttributes,\n\tdel: [...GlobalAttributes, 'cite', 'datetime'],\n\tdetails: [...GlobalAttributes, 'open'],\n\tdfn: GlobalAttributes,\n\tdialog: [...GlobalAttributes, 'open'],\n\tdiv: GlobalAttributes,\n\tdl: GlobalAttributes,\n\tdt: GlobalAttributes,\n\tem: GlobalAttributes,\n\tembed: [...GlobalAttributes, 'src', 'type', 'width', 'height', 'any*'],\n\tfieldset: [...GlobalAttributes, 'disabled', 'form', 'name'],\n\tfigcaption: GlobalAttributes,\n\tfigure: GlobalAttributes,\n\tfooter: GlobalAttributes,\n\tform: [...GlobalAttributes, 'accept-charset', 'action', 'autocomplete', 'enctype', 'method', 'name', 'novalidate', 'target'],\n\th1: GlobalAttributes,\n\th2: GlobalAttributes,\n\th3: GlobalAttributes,\n\th4: GlobalAttributes,\n\th5: GlobalAttributes,\n\th6: GlobalAttributes,\n\thead: GlobalAttributes,\n\theader: GlobalAttributes,\n\thgroup: GlobalAttributes,\n\thr: GlobalAttributes,\n\thtml: [...GlobalAttributes, 'manifest'],\n\ti: GlobalAttributes,\n\tiframe: [...GlobalAttributes, 'src', 'srcdoc', 'name', 'sandbox', 'allow', 'allowfullscreen', 'allowpaymentrequest', 'width', 'height', 'referrerpolicy', 'loading'],\n\timg: [...GlobalAttributes, 'alt', 'src', 'srcset', 'sizes', 'crossorigin', 'usemap', 'ismap', 'width', 'height', 'referrerpolicy', 'decoding', 'loading'],\n\tinput: [...GlobalAttributes, 'accept', 'alt', 'autocomplete', 'checked', 'dirname', 'disabled', 'form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'height', 'list', 'max', 'maxlength', 'min', 'minlength', 'multiple', 'name', 'pattern', 'placeholder', 'readonly', 'required', 'size', 'src', 'step', 'type', 'value', 'width'],\n\tins: [...GlobalAttributes, 'cite', 'datetime'],\n\tkbd: GlobalAttributes,\n\tlabel: [...GlobalAttributes, 'for'],\n\tlegend: GlobalAttributes,\n\tli: [...GlobalAttributes, 'value'],\n\tlink: [...GlobalAttributes, 'href', 'crossorigin', 'rel', 'as', 'media', 'hreflang', 'type', 'sizes', 'imagesrcset', 'imagesizes', 'referrerpolicy', 'integrity', 'color', 'disabled'],\n\tmain: GlobalAttributes,\n\tmap: [...GlobalAttributes, 'name'],\n\tmark: GlobalAttributes,\n\tmenu: GlobalAttributes,\n\tmeta: [...GlobalAttributes, 'name', 'http-equiv', 'content', 'charset'],\n\tmeter: [...GlobalAttributes, 'value', 'min', 'max', 'low', 'high', 'optimum'],\n\tnav: GlobalAttributes,\n\tnoscript: GlobalAttributes,\n\tobject: [...GlobalAttributes, 'data', 'type', 'name', 'usemap', 'form', 'width', 'height'],\n\tol: [...GlobalAttributes, 'reversed', 'start', 'type'],\n\toptgroup: [...GlobalAttributes, 'disabled', 'label'],\n\toption: [...GlobalAttributes, 'disabled', 'label', 'selected', 'value'],\n\toutput: [...GlobalAttributes, 'for', 'form', 'name'],\n\tp: GlobalAttributes,\n\tparam: [...GlobalAttributes, 'name', 'value'],\n\tpicture: GlobalAttributes,\n\tpre: GlobalAttributes,\n\tprogress: [...GlobalAttributes, 'value', 'max'],\n\tq: [...GlobalAttributes, 'cite'],\n\trp: GlobalAttributes,\n\trt: GlobalAttributes,\n\truby: GlobalAttributes,\n\ts: GlobalAttributes,\n\tsamp: GlobalAttributes,\n\tscript: [...GlobalAttributes, 'src', 'type', 'async', 'defer', 'crossorigin', 'integrity', 'referrerpolicy'],\n\tsection: GlobalAttributes,\n\tselect: [...GlobalAttributes, 'autocomplete', 'disabled', 'form', 'multiple', 'name', 'required', 'size'],\n\tslot: [...GlobalAttributes, 'name'],\n\tsmall: GlobalAttributes,\n\tsource: [...GlobalAttributes, 'src', 'type', 'srcset', 'sizes', 'media'],\n\tspan: GlobalAttributes,\n\tstrong: GlobalAttributes,\n\tstyle: [...GlobalAttributes, 'media'],\n\tsub: GlobalAttributes,\n\tsummary: GlobalAttributes,\n\tsup: GlobalAttributes,\n\ttable: GlobalAttributes,\n\ttbody: GlobalAttributes,\n\ttd: [...GlobalAttributes, 'colspan', 'rowspan', 'headers'],\n\ttemplate: GlobalAttributes,\n\ttextarea: [...GlobalAttributes, 'cols', 'dirname', 'disabled', 'form', 'maxlength', 'minlength', 'name', 'placeholder', 'readonly', 'required', 'rows', 'wrap'],\n\ttfoot: GlobalAttributes,\n\tth: [...GlobalAttributes, 'colspan', 'rowspan', 'headers', 'scope', 'abbr'],\n\tthead: GlobalAttributes,\n\ttime: [...GlobalAttributes, 'datetime'],\n\ttitle: GlobalAttributes,\n\ttr: GlobalAttributes,\n\ttrack: [...GlobalAttributes, 'default', 'kind', 'label', 'src', 'srclang'],\n\tu: GlobalAttributes,\n\tul: GlobalAttributes,\n\tvar: GlobalAttributes,\n\tvideo: [...GlobalAttributes, 'src', 'crossorigin', 'poster', 'preload', 'autoplay', 'playsinline', 'loop', 'muted', 'controls', 'width', 'height'],\n\twbr: GlobalAttributes,\n\t'virtual-scroller': GlobalAttributes\n};\n\n\nexport function hasNativeAttr(element: string | HTMLElement, attr: string): boolean {\n\tif (typeof element === 'string') {\n\t\treturn Attrs[element.toLowerCase()]?.includes(attr);\n\t} else if (element instanceof HTMLElement) {\n\t\tconst tagName = element.tagName.toLowerCase();\n\t\treturn Attrs[tagName]?.includes(attr);\n\t}\n\treturn false;\n}\n\nexport function getTagsForAttr(attr: string): string[] {\n\treturn Object.keys(Attrs).filter(tag => Attrs[tag].includes(attr));\n}\n\nexport function getAllAttributes(tag?: string): string[] {\n\tif (tag) {\n\t\treturn Attrs[tag];\n\t}\n\treturn GlobalAttributes.slice();\n}"]}
@@ -1,16 +1,37 @@
1
1
  export interface DirectiveNodeOptions {
2
- attributes?: string[];
3
- nextSiblingDirectives?: string[];
2
+ inputs?: string[];
3
+ outputs?: string[];
4
+ }
5
+ declare class DirectiveNodeInfo {
6
+ private inputs?;
7
+ private outputs?;
8
+ constructor(inputs?: string[] | undefined, outputs?: string[] | undefined);
9
+ hasAttributes(): boolean;
10
+ hasInputs(): boolean;
11
+ hasOutputs(): boolean;
12
+ getAttributes(): string[] | undefined;
13
+ getInputs(): string[] | undefined;
14
+ getOutputs(): string[] | undefined;
15
+ hasAttribute(attributeName: string): boolean;
16
+ hasInput(inputName: string): boolean;
17
+ hasOutput(outputName: string): boolean;
4
18
  }
5
19
  export declare class DirectiveRegistry {
6
20
  private directives;
7
21
  register(directiveName: string, options?: DirectiveNodeOptions): void;
8
22
  replace(directiveName: string, options: DirectiveNodeOptions): void;
9
- has(directiveName: string): boolean;
10
- get(directiveName: string): DirectiveNodeOptions | undefined;
23
+ has(attributeName: string): boolean;
24
+ get(directiveName: string): DirectiveNodeInfo | undefined;
11
25
  hasAttributes(directiveName: string): boolean;
26
+ hasInputs(directiveName: string): boolean;
27
+ hasOutputs(directiveName: string): boolean;
12
28
  getAttributes(directiveName: string): string[] | undefined;
13
- hasNextSiblingDirectives(directiveName: string): boolean;
14
- getNextSiblingDirectives(directiveName: string): string[] | undefined;
29
+ getInputs(directiveName: string): string[] | undefined;
30
+ getOutputs(directiveName: string): string[] | undefined;
31
+ hasAttribute(directiveName: string, attributeName: string): boolean;
32
+ hasInput(directiveName: string, inputName: string): boolean;
33
+ hasOutput(directiveName: string, outputName: string): boolean;
34
+ filterDirectives(attributes: string[]): string[];
15
35
  }
16
36
  export declare const directiveRegistry: DirectiveRegistry;
37
+ export {};
@@ -1,34 +1,96 @@
1
+ class DirectiveNodeInfo {
2
+ constructor(inputs, outputs) {
3
+ this.inputs = inputs;
4
+ this.outputs = outputs;
5
+ }
6
+ hasAttributes() {
7
+ return this.hasInputs() || this.hasOutputs();
8
+ }
9
+ hasInputs() {
10
+ return (this.inputs?.length ?? 0) > 0;
11
+ }
12
+ hasOutputs() {
13
+ return (this.outputs?.length ?? 0) > 0;
14
+ }
15
+ getAttributes() {
16
+ if (this.inputs && this.outputs) {
17
+ return this.inputs.concat(this.outputs);
18
+ }
19
+ else if (this.inputs) {
20
+ return this.inputs;
21
+ }
22
+ else if (this.outputs) {
23
+ return this.outputs;
24
+ }
25
+ return undefined;
26
+ }
27
+ getInputs() {
28
+ return this.inputs;
29
+ }
30
+ getOutputs() {
31
+ return this.outputs;
32
+ }
33
+ hasAttribute(attributeName) {
34
+ return this.hasInput(attributeName) || this.hasOutput(attributeName);
35
+ }
36
+ hasInput(inputName) {
37
+ return this.inputs?.includes(inputName) || false;
38
+ }
39
+ hasOutput(outputName) {
40
+ return this.outputs?.includes(outputName) || false;
41
+ }
42
+ }
1
43
  export class DirectiveRegistry {
2
44
  constructor() {
3
45
  this.directives = new Map();
4
46
  }
5
47
  register(directiveName, options) {
6
48
  if (!this.directives.has(directiveName)) {
7
- this.directives.set(directiveName, options ?? {});
49
+ const info = new DirectiveNodeInfo(options?.inputs, options?.outputs);
50
+ this.directives.set(directiveName, info);
8
51
  }
9
52
  }
10
53
  replace(directiveName, options) {
11
54
  if (this.directives.has(directiveName)) {
12
- this.directives.set(directiveName, options);
55
+ const info = new DirectiveNodeInfo(options?.inputs, options?.outputs);
56
+ this.directives.set(directiveName, info);
13
57
  }
14
58
  }
15
- has(directiveName) {
16
- return this.directives.has(directiveName);
59
+ has(attributeName) {
60
+ return this.directives.has(attributeName);
17
61
  }
18
62
  get(directiveName) {
19
63
  return this.directives.get(directiveName);
20
64
  }
21
65
  hasAttributes(directiveName) {
22
- return (this.directives.get(directiveName)?.attributes?.length ?? 0) > 0;
66
+ return this.hasInputs(directiveName) || this.hasOutputs(directiveName);
67
+ }
68
+ hasInputs(directiveName) {
69
+ return this.directives.get(directiveName)?.hasInputs() || false;
70
+ }
71
+ hasOutputs(directiveName) {
72
+ return this.directives.get(directiveName)?.hasOutputs() || false;
23
73
  }
24
74
  getAttributes(directiveName) {
25
- return this.directives.get(directiveName)?.attributes;
75
+ return this.directives.get(directiveName)?.getAttributes();
76
+ }
77
+ getInputs(directiveName) {
78
+ return this.directives.get(directiveName)?.getInputs();
79
+ }
80
+ getOutputs(directiveName) {
81
+ return this.directives.get(directiveName)?.getOutputs();
82
+ }
83
+ hasAttribute(directiveName, attributeName) {
84
+ return this.directives.get(directiveName)?.hasAttribute(attributeName) || false;
85
+ }
86
+ hasInput(directiveName, inputName) {
87
+ return this.directives.get(directiveName)?.hasInput(inputName) || false;
26
88
  }
27
- hasNextSiblingDirectives(directiveName) {
28
- return (this.directives.get(directiveName)?.nextSiblingDirectives?.length ?? 0) > 0;
89
+ hasOutput(directiveName, outputName) {
90
+ return this.directives.get(directiveName)?.hasOutput(outputName) || false;
29
91
  }
30
- getNextSiblingDirectives(directiveName) {
31
- return this.directives.get(directiveName)?.nextSiblingDirectives;
92
+ filterDirectives(attributes) {
93
+ return attributes.filter(name => this.has(name));
32
94
  }
33
95
  }
34
96
  export const directiveRegistry = new DirectiveRegistry();
@@ -1 +1 @@
1
- {"version":3,"file":"register-directive.js","sourceRoot":"","sources":["../../../src/elements/directives/register-directive.ts"],"names":[],"mappings":"AA8BA,MAAM,OAAO,iBAAiB;IAA9B;QAKS,eAAU,GAAG,IAAI,GAAG,EAAgC,CAAC;IAiF9D,CAAC;IAxEA,QAAQ,CAAC,aAAqB,EAAE,OAA8B;QAC7D,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACxC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;SAClD;IACF,CAAC;IAQD,OAAO,CAAC,aAAqB,EAAE,OAA6B;QAC3D,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACvC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;SAC5C;IACF,CAAC;IAOD,GAAG,CAAC,aAAqB;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC3C,CAAC;IAOD,GAAG,CAAC,aAAqB;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC3C,CAAC;IAOD,aAAa,CAAC,aAAqB;QAClC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1E,CAAC;IAOD,aAAa,CAAC,aAAqB;QAClC,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,UAAU,CAAC;IACvD,CAAC;IAOD,wBAAwB,CAAC,aAAqB;QAC7C,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,qBAAqB,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACrF,CAAC;IAOD,wBAAwB,CAAC,aAAqB;QAC7C,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,qBAAqB,CAAC;IAClE,CAAC;CAED;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC","sourcesContent":["\n\nexport interface DirectiveNodeOptions {\n\n\t/**\n\t * list of attributes name \n\t * consists of inputs and outputs and normal attributes\n\t */\n\tattributes?: string[];\n\n\t/**\n\t * the `nextSiblingDirectives` will be one of the names list or none if not followed by any.\n\t * \n\t * consider writing html as \n\t * \n\t * ```html\n\t * <if condition=\"user.name === 'alex'\" >Alex is {{user.age}} years old.</if>\n\t * <else-if condition=\"user.name === 'sara'\" >Sara working at {{user.company.name}}.</else-if>\n\t * <else-if condition=\"user.name === 'jon'\" >Jon used to play {{user.gameName}}.</else-if>\n\t * <else>{{user.name}} is unknown.</else>\n\t * ```\n\t * - the if directive should register nextSiblingDirectives as ['else', 'else-if'],\n\t * \n\t * - the else-if directive should register nextSiblingDirectives as ['else', 'else-if'] too,\n\t * \n\t * - the else directive should not register any nextSiblingDirectives, as [].\n\t */\n\tnextSiblingDirectives?: string[];\n}\n\nexport class DirectiveRegistry {\n\n\t/**\n\t * store options info about directives\n\t */\n\tprivate directives = new Map<string, DirectiveNodeOptions>();\n\n\t/**\n\t * register a directive with a name,\n\t * if the directive name exists, will not replace the old directive options\n\t * @param directiveName \n\t * @param options contain the attributes of the registered directive name\n\t * @override\n\t */\n\tregister(directiveName: string, options?: DirectiveNodeOptions): void {\n\t\tif (!this.directives.has(directiveName)) {\n\t\t\tthis.directives.set(directiveName, options ?? {});\n\t\t}\n\t}\n\n\t/**\n\t * replace the current options with a new one.\n\t * if the directive name not exists, no set options will be done\n\t * @param directiveName \n\t * @param options to be replaced\n\t */\n\treplace(directiveName: string, options: DirectiveNodeOptions): void {\n\t\tif (this.directives.has(directiveName)) {\n\t\t\tthis.directives.set(directiveName, options);\n\t\t}\n\t}\n\n\t/**\n\t * check if directive name is registered\n\t * @param directiveName \n\t * @returns `boolean`\n\t */\n\thas(directiveName: string): boolean {\n\t\treturn this.directives.has(directiveName);\n\t}\n\n\t/**\n\t * get the DirectiveOptions for a directive name\n\t * @param directiveName \n\t * @returns `DirectiveOptions` if the name has been registered, otherwise `undefined`\n\t */\n\tget(directiveName: string): DirectiveNodeOptions | undefined {\n\t\treturn this.directives.get(directiveName);\n\t}\n\n\t/**\n\t * check if the options registered with a `directiveName` has attributes array\n\t * @param directiveName \n\t * @returns `boolean`\n\t */\n\thasAttributes(directiveName: string): boolean {\n\t\treturn (this.directives.get(directiveName)?.attributes?.length ?? 0) > 0;\n\t}\n\n\t/**\n\t * get the value of the registered attributes with a directive\n\t * @param directiveName \n\t * @returns array of strings if found, otherwise `undefined`\n\t */\n\tgetAttributes(directiveName: string): string[] | undefined {\n\t\treturn this.directives.get(directiveName)?.attributes;\n\t}\n\n\t/**\n\t * check if the options registered with a `directiveName` has next sibling directives\n\t * @param directiveName \n\t * @returns `boolean`\n\t */\n\thasNextSiblingDirectives(directiveName: string): boolean {\n\t\treturn (this.directives.get(directiveName)?.nextSiblingDirectives?.length ?? 0) > 0;\n\t}\n\n\t/**\n\t * get the value of the registered next possible sibling directives for a directive name\n\t * @param directiveName \n\t * @returns array of strings if found, otherwise `undefined`\n\t */\n\tgetNextSiblingDirectives(directiveName: string): string[] | undefined {\n\t\treturn this.directives.get(directiveName)?.nextSiblingDirectives;\n\t}\n\n}\n\nexport const directiveRegistry = new DirectiveRegistry();\n"]}
1
+ {"version":3,"file":"register-directive.js","sourceRoot":"","sources":["../../../src/elements/directives/register-directive.ts"],"names":[],"mappings":"AAeA,MAAM,iBAAiB;IACtB,YAAoB,MAAiB,EAAU,OAAkB;QAA7C,WAAM,GAAN,MAAM,CAAW;QAAU,YAAO,GAAP,OAAO,CAAW;IAAI,CAAC;IAEtE,aAAa;QACZ,OAAO,IAAI,CAAC,SAAS,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;IAC9C,CAAC;IAED,SAAS;QACR,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACvC,CAAC;IAED,UAAU;QACT,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IAED,aAAa;QACZ,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE;YAChC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACxC;aAAM,IAAI,IAAI,CAAC,MAAM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F,CAAC;IAQD,QAAQ,CAAC,aAAqB,EAAE,SAAiB;QAChD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC;IACzE,CAAC;IAQD,SAAS,CAAC,aAAqB,EAAE,UAAkB;QAClD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC;IAC3E,CAAC;IAED,gBAAgB,CAAC,UAAoB;QACpC,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;CAED;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC","sourcesContent":["\n\nexport interface DirectiveNodeOptions {\n\n\t/**\n\t * list of inputs view name\n\t */\n\tinputs?: string[];\n\n\t/**\n\t * list of outputs view name\n\t */\n\toutputs?: string[];\n}\n\nclass DirectiveNodeInfo {\n\tconstructor(private inputs?: string[], private outputs?: string[]) { }\n\n\thasAttributes(): boolean {\n\t\treturn this.hasInputs() || this.hasOutputs();\n\t}\n\n\thasInputs(): boolean {\n\t\treturn (this.inputs?.length ?? 0) > 0;\n\t}\n\n\thasOutputs(): boolean {\n\t\treturn (this.outputs?.length ?? 0) > 0;\n\t}\n\n\tgetAttributes(): string[] | undefined {\n\t\tif (this.inputs && this.outputs) {\n\t\t\treturn this.inputs.concat(this.outputs);\n\t\t} else if (this.inputs) {\n\t\t\treturn this.inputs;\n\t\t} else if (this.outputs) {\n\t\t\treturn this.outputs;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tgetInputs(): string[] | undefined {\n\t\treturn this.inputs;\n\t}\n\n\tgetOutputs(): string[] | undefined {\n\t\treturn this.outputs;\n\t}\n\n\thasAttribute(attributeName: string): boolean {\n\t\treturn this.hasInput(attributeName) || this.hasOutput(attributeName);\n\t}\n\n\thasInput(inputName: string): boolean {\n\t\treturn this.inputs?.includes(inputName) || false;\n\t}\n\n\thasOutput(outputName: string): boolean {\n\t\treturn this.outputs?.includes(outputName) || false;\n\t}\n\n}\n\nexport class DirectiveRegistry {\n\n\t/**\n\t * store options info about directives\n\t */\n\tprivate directives = new Map<string, DirectiveNodeInfo>();\n\n\t/**\n\t * register a directive with a name,\n\t * \n\t * the directive could be a structural directive or an attribute directive.\n\t * \n\t * if the directive name exists, will not replace the old directive options.\n\t * @param directiveName \n\t * @param options contain the attributes of the registered directive name\n\t * @override\n\t */\n\tregister(directiveName: string, options?: DirectiveNodeOptions): void {\n\t\tif (!this.directives.has(directiveName)) {\n\t\t\tconst info = new DirectiveNodeInfo(options?.inputs, options?.outputs);\n\t\t\tthis.directives.set(directiveName, info);\n\t\t}\n\t}\n\n\t/**\n\t * replace the current options with a new one.\n\t * \n\t * the directive could be a structural directive or an attribute directive.\n\t * \n\t * if the directive name not exists, no set options will be done\n\t * @param directiveName \n\t * @param options to be replaced\n\t */\n\treplace(directiveName: string, options: DirectiveNodeOptions): void {\n\t\tif (this.directives.has(directiveName)) {\n\t\t\tconst info = new DirectiveNodeInfo(options?.inputs, options?.outputs);\n\t\t\tthis.directives.set(directiveName, info);\n\t\t}\n\t}\n\n\t/**\n\t * check if directive name is registered\n\t * @param directiveName \n\t * @returns `boolean`\n\t */\n\thas(attributeName: string): boolean {\n\t\treturn this.directives.has(attributeName);\n\t}\n\n\t/**\n\t * get the DirectiveOptions for a directive name\n\t * @param directiveName \n\t * @returns `DirectiveOptions` if the name has been registered, otherwise `undefined`\n\t */\n\tget(directiveName: string): DirectiveNodeInfo | undefined {\n\t\treturn this.directives.get(directiveName);\n\t}\n\n\t/**\n\t * check if the options registered with a `directiveName` has attributes array\n\t * @param directiveName \n\t * @returns `boolean`\n\t */\n\thasAttributes(directiveName: string): boolean {\n\t\treturn this.hasInputs(directiveName) || this.hasOutputs(directiveName);\n\t}\n\n\thasInputs(directiveName: string): boolean {\n\t\treturn this.directives.get(directiveName)?.hasInputs() || false;\n\t}\n\n\thasOutputs(directiveName: string): boolean {\n\t\treturn this.directives.get(directiveName)?.hasOutputs() || false;\n\t}\n\n\t/**\n\t * get the value of the registered inputs and outputs by directive name\n\t * @param directiveName \n\t * @returns array of strings if found, otherwise `undefined`\n\t */\n\tgetAttributes(directiveName: string): string[] | undefined {\n\t\treturn this.directives.get(directiveName)?.getAttributes();\n\t}\n\n\t/**\n\t * get the value of the registered inputs by directive name\n\t * @param directiveName \n\t * @returns array of strings if found, otherwise `undefined`\n\t */\n\tgetInputs(directiveName: string): string[] | undefined {\n\t\treturn this.directives.get(directiveName)?.getInputs();\n\t}\n\n\t/**\n\t * get the value of the registered outputs by directive name\n\t * @param directiveName \n\t * @returns array of strings if found, otherwise `undefined`\n\t */\n\tgetOutputs(directiveName: string): string[] | undefined {\n\t\treturn this.directives.get(directiveName)?.getOutputs();\n\t}\n\n\t/**\n\t * check if a directive has a attribute\n\t * @param directiveName \n\t * @param attributeName \n\t * @returns \n\t */\n\thasAttribute(directiveName: string, attributeName: string): boolean {\n\t\treturn this.directives.get(directiveName)?.hasAttribute(attributeName) || false;\n\t}\n\n\t/**\n\t * check if has input\n\t * @param directiveName \n\t * @param inputName \n\t * @returns \n\t */\n\thasInput(directiveName: string, inputName: string): boolean {\n\t\treturn this.directives.get(directiveName)?.hasInput(inputName) || false;\n\t}\n\n\t/**\n\t * check if has output\n\t * @param directiveName \n\t * @param outputName \n\t * @returns \n\t */\n\thasOutput(directiveName: string, outputName: string): boolean {\n\t\treturn this.directives.get(directiveName)?.hasOutput(outputName) || false;\n\t}\n\n\tfilterDirectives(attributes: string[]): string[] {\n\t\treturn attributes.filter(name => this.has(name));\n\t}\n\n}\n\nexport const directiveRegistry = new DirectiveRegistry();\n"]}
@@ -1,4 +1,4 @@
1
- import { DOMElementNode, DOMDirectiveNode, DOMNode, DOMChild } from '../ast/dom.js';
1
+ import { DomElementNode, DomStructuralDirectiveNode, DomNode, DomChild } from '../ast/dom.js';
2
2
  export declare class EscapeHTMLCharacter {
3
3
  static ESCAPE_MAP: {
4
4
  [key: string]: string;
@@ -23,7 +23,7 @@ export declare class NodeParser {
23
23
  private propertyValue;
24
24
  private propType;
25
25
  private escaper;
26
- parse(html: string): DOMChild[];
26
+ parse(html: string): DomChild[];
27
27
  private reset;
28
28
  private parseText;
29
29
  private parseTag;
@@ -35,13 +35,15 @@ export declare class NodeParser {
35
35
  private parseInputOutput;
36
36
  private parsePropertyValue;
37
37
  private popElement;
38
- checkNode(node: DOMElementNode): DOMElementNode | DOMDirectiveNode;
38
+ checkNode(node: DomElementNode): DomElementNode | DomStructuralDirectiveNode;
39
39
  private extractDirectiveAttributesFromNode;
40
+ private extractDirectiveNames;
41
+ private getAttributeDirectives;
40
42
  }
41
43
  export declare class HTMLParser {
42
44
  nodeParser: NodeParser;
43
- parse(html: string): DOMChild[];
44
- toDomRootNode(html: string): DOMNode;
45
- stringify(stack: DOMNode[]): string;
45
+ parse(html: string): DomChild[];
46
+ toDomRootNode(html: string): DomNode;
47
+ stringify(stack?: DomNode[]): string;
46
48
  }
47
49
  export declare const htmlParser: HTMLParser;
@@ -1,5 +1,5 @@
1
1
  import { isEmptyElement } from '../attributes/tags.js';
2
- import { DOMElementNode, CommentNode, parseTextChild, TextContent, LiveTextContent, DOMFragmentNode, DOMDirectiveNode } from '../ast/dom.js';
2
+ import { DomElementNode, CommentNode, parseTextChild, TextContent, LiveTextContent, DomFragmentNode, DomStructuralDirectiveNode, DomAttributeDirectiveNode } from '../ast/dom.js';
3
3
  import { directiveRegistry } from '../directives/register-directive.js';
4
4
  export class EscapeHTMLCharacter {
5
5
  constructor() {
@@ -129,7 +129,7 @@ export class NodeParser {
129
129
  }
130
130
  parseOpenTag(token) {
131
131
  if (token === '>') {
132
- this.stackTrace.push(new DOMElementNode(this.tempText));
132
+ this.stackTrace.push(new DomElementNode(this.tempText));
133
133
  if (isEmptyElement(this.tempText)) {
134
134
  this.popElement();
135
135
  }
@@ -141,7 +141,7 @@ export class NodeParser {
141
141
  return this.parseOpenTag;
142
142
  }
143
143
  else if (/\s/.test(token)) {
144
- this.stackTrace.push(new DOMElementNode(this.tempText));
144
+ this.stackTrace.push(new DomElementNode(this.tempText));
145
145
  this.tempText = '';
146
146
  this.propType = 'attr';
147
147
  return this.parsePropertyName;
@@ -282,11 +282,11 @@ export class NodeParser {
282
282
  const element = this.stackTrace.pop();
283
283
  if (element) {
284
284
  const parent = this.stackTrace.pop();
285
- if (parent && parent instanceof DOMElementNode) {
285
+ if (parent && parent instanceof DomElementNode) {
286
286
  if (typeof element === 'string') {
287
287
  parent.addTextChild(element);
288
288
  }
289
- else if (element instanceof DOMElementNode) {
289
+ else if (element instanceof DomElementNode) {
290
290
  parent.addChild(this.checkNode(element));
291
291
  }
292
292
  else {
@@ -298,7 +298,7 @@ export class NodeParser {
298
298
  if (typeof element === 'string') {
299
299
  parseTextChild(element).forEach(text => this.childStack.push(text));
300
300
  }
301
- else if (element instanceof DOMElementNode) {
301
+ else if (element instanceof DomElementNode) {
302
302
  this.childStack.push(this.checkNode(element));
303
303
  }
304
304
  else {
@@ -310,7 +310,8 @@ export class NodeParser {
310
310
  checkNode(node) {
311
311
  const attributes = node.attributes;
312
312
  if (attributes) {
313
- let temp = attributes.find(attr => attr.name === 'is');
313
+ let temp;
314
+ temp = attributes.find(attr => attr.name === 'is');
314
315
  if (temp) {
315
316
  attributes.splice(attributes.indexOf(temp), 1);
316
317
  node.is = temp.value;
@@ -331,47 +332,62 @@ export class NodeParser {
331
332
  node.addOutput(templateAttrs.name.substring(2), templateAttrs.value);
332
333
  });
333
334
  }
334
- temp = attributes.find(attr => attr.name.startsWith('*'));
335
- if (temp) {
336
- attributes.splice(attributes.indexOf(temp), 1);
337
- const isTemplate = node.tagName === 'template';
338
- const directiveNode = isTemplate ? new DOMFragmentNode(node.children) : node;
339
- const directive = new DOMDirectiveNode(temp.name, temp.value ?? '', directiveNode);
340
- const directiveName = temp.name.substring(1);
341
- if (isTemplate) {
342
- directive.inputs = node.inputs;
343
- directive.outputs = node.outputs;
344
- directive.attributes = node.attributes;
345
- directive.templateAttrs = node.templateAttrs;
346
- }
347
- else if (directiveRegistry.hasAttributes(directiveName)) {
348
- this.extractDirectiveAttributesFromNode(directiveName, directive, node);
335
+ }
336
+ const directiveNames = this.extractDirectiveNames(node);
337
+ let sdName;
338
+ if (directiveNames.length) {
339
+ const directives = [];
340
+ directiveNames.forEach(attributeName => {
341
+ if (attributeName.startsWith('*')) {
342
+ if (sdName) {
343
+ console.error(`Only one Structural Directive is allowed on an element [${sdName}, ${attributeName}]`);
344
+ return;
345
+ }
346
+ sdName = attributeName;
347
+ return;
349
348
  }
350
- return directive;
351
- }
352
- if (directiveRegistry.has(node.tagName)) {
353
- temp = attributes.find(attr => attr.name === 'expression');
354
- if (temp) {
355
- attributes.splice(attributes.indexOf(temp), 1);
349
+ const directive = new DomAttributeDirectiveNode(attributeName);
350
+ if (directiveRegistry.get(attributeName).hasAttributes()) {
351
+ this.extractDirectiveAttributesFromNode(attributeName, directive, node);
356
352
  }
357
- const directiveNode = new DOMFragmentNode(node.children);
358
- const directive = new DOMDirectiveNode('*' + node.tagName, temp?.value ?? '', directiveNode);
359
- this.extractDirectiveAttributesFromNode(node.tagName, directive, node);
360
- return directive;
353
+ directives.push(directive);
354
+ });
355
+ if (directives.length) {
356
+ node.attributeDirectives = directives;
361
357
  }
362
358
  }
363
- else if (directiveRegistry.has(node.tagName)) {
364
- return new DOMDirectiveNode('*' + node.tagName, '', new DOMFragmentNode(node.children));
359
+ if (sdName) {
360
+ const temp = node.attributes.filter(attr => attr.name == sdName)[0];
361
+ node.attributes.splice(node.attributes.indexOf(temp), 1);
362
+ const isTemplate = node.tagName === 'template';
363
+ const directiveNode = isTemplate ? new DomFragmentNode(node.children) : node;
364
+ const directive = (typeof temp?.value === 'boolean')
365
+ ? new DomStructuralDirectiveNode(temp.name, directiveNode)
366
+ : new DomStructuralDirectiveNode(temp.name, directiveNode, String(temp.value));
367
+ const directiveName = temp.name.substring(1);
368
+ if (isTemplate) {
369
+ directive.inputs = node.inputs;
370
+ directive.outputs = node.outputs;
371
+ directive.attributes = node.attributes;
372
+ directive.templateAttrs = node.templateAttrs;
373
+ }
374
+ else if (directiveRegistry.hasAttributes(directiveName)) {
375
+ this.extractDirectiveAttributesFromNode(directiveName, directive, node);
376
+ }
377
+ return directive;
365
378
  }
366
379
  return node;
367
380
  }
368
381
  extractDirectiveAttributesFromNode(directiveName, directive, node) {
369
382
  const attributes = directiveRegistry.getAttributes(directiveName);
383
+ if (!attributes) {
384
+ return;
385
+ }
370
386
  const filterByAttrName = createFilterByAttrName(attributes);
387
+ directive.attributes = node.attributes?.filter(filterByAttrName);
371
388
  directive.inputs = node.inputs?.filter(filterByAttrName);
372
389
  directive.outputs = node.outputs?.filter(filterByAttrName);
373
390
  directive.twoWayBinding = node.twoWayBinding?.filter(filterByAttrName);
374
- directive.attributes = node.attributes?.filter(filterByAttrName);
375
391
  directive.templateAttrs = node.templateAttrs?.filter(filterByAttrName);
376
392
  node.inputs && directive.inputs?.forEach(createArrayCleaner(node.inputs));
377
393
  node.outputs && directive.outputs?.forEach(createArrayCleaner(node.outputs));
@@ -379,6 +395,28 @@ export class NodeParser {
379
395
  node.attributes && directive.attributes?.forEach(createArrayCleaner(node.attributes));
380
396
  node.templateAttrs && directive.templateAttrs?.forEach(createArrayCleaner(node.templateAttrs));
381
397
  }
398
+ extractDirectiveNames(node) {
399
+ const names = [];
400
+ if (node.attributes?.length) {
401
+ names.push(...this.getAttributeDirectives(node.attributes));
402
+ }
403
+ if (node.inputs?.length) {
404
+ names.push(...this.getAttributeDirectives(node.inputs));
405
+ }
406
+ if (node.twoWayBinding?.length) {
407
+ names.push(...this.getAttributeDirectives(node.twoWayBinding));
408
+ }
409
+ if (node.templateAttrs?.length) {
410
+ names.push(...this.getAttributeDirectives(node.templateAttrs));
411
+ }
412
+ if (node.outputs?.length) {
413
+ names.push(...this.getAttributeDirectives(node.outputs));
414
+ }
415
+ return names;
416
+ }
417
+ getAttributeDirectives(attributes) {
418
+ return directiveRegistry.filterDirectives(attributes.map(attr => attr.name));
419
+ }
382
420
  }
383
421
  function createFilterByAttrName(attributes) {
384
422
  return (attr) => attributes.includes(attr.name);
@@ -396,13 +434,13 @@ export class HTMLParser {
396
434
  toDomRootNode(html) {
397
435
  let stack = this.nodeParser.parse(html);
398
436
  if (!stack || stack.length === 0) {
399
- return new DOMFragmentNode([new TextContent('')]);
437
+ return new DomFragmentNode([new TextContent('')]);
400
438
  }
401
439
  else if (stack?.length === 1) {
402
440
  return stack[0];
403
441
  }
404
442
  else {
405
- return new DOMFragmentNode(stack);
443
+ return new DomFragmentNode(stack);
406
444
  }
407
445
  }
408
446
  stringify(stack) {
@@ -417,7 +455,7 @@ export class HTMLParser {
417
455
  else if (node instanceof CommentNode) {
418
456
  html += `<!-- ${node.comment} -->`;
419
457
  }
420
- else if (node instanceof DOMElementNode) {
458
+ else if (node instanceof DomElementNode) {
421
459
  let attrs = '';
422
460
  if (node.attributes) {
423
461
  attrs += node.attributes.map(attr => `${attr.name}="${attr.value}"`).join(' ') + ' ';
@@ -1 +1 @@
1
- {"version":3,"file":"html-parser.js","sourceRoot":"","sources":["../../../src/elements/node/html-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACN,cAAc,EAAE,WAAW,EAAE,cAAc,EAC3C,WAAW,EAAE,eAAe,EAAE,eAAe,EAC7C,gBAAgB,EAEhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAMxE,MAAM,OAAO,mBAAmB;IAW/B;QACC,MAAM,iBAAiB,GAAG,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG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ACD;QACF,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACb,CAAC;CAED;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC","sourcesContent":["import { isEmptyElement } from '../attributes/tags.js';\nimport {\n\tDOMElementNode, CommentNode, parseTextChild,\n\tTextContent, LiveTextContent, DOMFragmentNode,\n\tDOMDirectiveNode, DOMNode, DOMChild,\n\tElementAttribute, Attribute\n} from '../ast/dom.js';\nimport { directiveRegistry } from '../directives/register-directive.js';\n\ntype Token = (token: string) => Token;\n\ntype ChildNode = DOMElementNode | CommentNode | string;\n\nexport class EscapeHTMLCharacter {\n\tstatic ESCAPE_MAP: { [key: string]: string } = {\n\t\t'&amp;': '&',\n\t\t'&lt;': '<',\n\t\t'&gt;': '>',\n\t\t'&quot;': '\"',\n\t\t'&#x27;': \"'\",\n\t\t'&#x60;': '`'\n\t};\n\ttest: RegExp;\n\treplace: RegExp;\n\tconstructor() {\n\t\tconst escapeRegexSource = '(?:' + Object.keys(EscapeHTMLCharacter.ESCAPE_MAP).join('|') + ')';\n\t\tthis.test = new RegExp(escapeRegexSource);\n\t\tthis.replace = new RegExp(escapeRegexSource, 'g');\n\t}\n\n\tescaper(match: string): string {\n\t\treturn EscapeHTMLCharacter.ESCAPE_MAP[match];\n\t}\n\n\tunescape(text: string): string {\n\t\tif (!text) {\n\t\t\treturn text;\n\t\t}\n\t\treturn this.test.test(text) ? text.replace(this.replace, this.escaper) : text;\n\t}\n}\n\nexport class NodeParser {\n\n\tprivate index: number;\n\tprivate stateFn: Token;\n\n\tprivate tagNameRegExp = /[\\-\\.0-9_a-z\\xB7\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u037D\\u037F-\\u1FFF\\u200C\\u200D\\u203F\\u2040\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]|[\\uD800-\\uDB7F][\\uDC00-\\uDFFF]/;\n\n\tprivate childStack: DOMChild[];\n\tprivate stackTrace: ChildNode[];\n\n\tprivate get currentNode(): DOMElementNode {\n\t\treturn this.stackTrace[this.stackTrace.length - 1] as DOMElementNode;\n\t}\n\n\tprivate commentOpenCount = 0;\n\tprivate commentCloseCount = 0;\n\n\tprivate tempText: string;\n\n\tprivate propertyName: string;\n\tprivate propertyValue: string;\n\tprivate propType: 'attr' | 'ref-name' | 'input' | 'output' | 'two-way';\n\n\tprivate escaper = new EscapeHTMLCharacter();\n\n\tparse(html: string)/*: DomNode*/ {\n\t\tthis.reset();\n\t\tfor (; this.index < html.length; this.index++) {\n\t\t\tthis.stateFn = this.stateFn(html[this.index]);\n\t\t}\n\t\tif (this.tempText && this.stateFn === this.parseText) {\n\t\t\tthis.stateFn('<');\n\t\t}\n\t\tif (this.stackTrace.length > 0) {\n\t\t\tconsole.error(this.stackTrace);\n\t\t\tthrow new Error(`error parsing html, had ${this.stackTrace.length} element, with no closing tag`);\n\t\t}\n\t\tlet stack = this.childStack;\n\t\tthis.reset();\n\t\treturn stack;\n\t}\n\n\tprivate reset() {\n\t\tthis.index = 0;\n\t\tthis.childStack = [];\n\t\tthis.stackTrace = [];\n\t\tthis.propType = 'attr';\n\t\tthis.commentOpenCount = 0;\n\t\tthis.commentCloseCount = 0;\n\t\tthis.stateFn = this.parseText;\n\t\tthis.propertyName = this.propertyValue = this.tempText = '';\n\t}\n\n\tprivate parseText(token: string) {\n\t\tif (token === '<') {\n\t\t\tif (this.tempText) {\n\t\t\t\tthis.tempText = this.escaper.unescape(this.tempText);\n\t\t\t\tthis.stackTrace.push(this.tempText);\n\t\t\t\tthis.popElement();\n\t\t\t\tthis.tempText = '';\n\t\t\t}\n\t\t\treturn this.parseTag;\n\t\t}\n\t\tthis.tempText += token;\n\t\treturn this.parseText;\n\t}\n\n\tprivate parseTag(token: string) {\n\t\tif (token === '/') {\n\t\t\treturn this.parseCloseTag;\n\t\t}\n\t\tif (token === '!') {\n\t\t\tthis.commentOpenCount = 0;\n\t\t\tthis.commentCloseCount = 0;\n\t\t\treturn this.parseComment;\n\t\t}\n\t\tthis.index--;\n\t\treturn this.parseOpenTag;\n\t}\n\n\tprivate parseComment(token: string) {\n\t\tif (token === '-') {\n\t\t\tif (this.commentOpenCount < 2) {\n\t\t\t\tthis.commentOpenCount++;\n\t\t\t} else {\n\t\t\t\tthis.commentCloseCount++;\n\t\t\t}\n\t\t\treturn this.parseComment;\n\t\t}\n\t\telse if (token === '>' && this.commentCloseCount === 2) {\n\t\t\tthis.tempText = this.escaper.unescape(this.tempText);\n\t\t\tthis.stackTrace.push(new CommentNode(this.tempText.trim()));\n\t\t\tthis.popElement();\n\t\t\tthis.tempText = '';\n\t\t\tthis.commentOpenCount = 0;\n\t\t\tthis.commentCloseCount = 0;\n\t\t\treturn this.parseText;\n\t\t}\n\t\tif (this.commentCloseCount > 0) {\n\t\t\tfor (let i = 0; i < this.commentCloseCount; i++) {\n\t\t\t\tthis.tempText += '-';\n\t\t\t}\n\t\t\tthis.commentCloseCount = 0;\n\t\t}\n\t\tthis.tempText += token;\n\t\treturn this.parseComment;\n\t}\n\n\tprivate parseCloseTag(token: string) {\n\t\tif (token === '>') {\n\t\t\tif (!isEmptyElement(this.currentNode.tagName)\n\t\t\t\t&& this.currentNode.tagName.trim().toLowerCase() !== this.tempText.trim().toLowerCase()\n\t\t\t) {\n\t\t\t\tthrow 'Wrong closed tag at char ' + this.index;\n\t\t\t}\n\t\t\tthis.popElement();\n\t\t\tthis.tempText = '';\n\t\t\treturn this.parseText;\n\t\t}\n\t\tthis.tempText += token;\n\t\treturn this.parseCloseTag;\n\t}\n\n\tprivate parseOpenTag(token: string) {\n\t\tif (token === '>') {\n\t\t\tthis.stackTrace.push(new DOMElementNode(this.tempText));\n\t\t\tif (isEmptyElement(this.tempText)) {\n\t\t\t\tthis.popElement();\n\t\t\t}\n\t\t\tthis.tempText = '';\n\t\t\treturn this.parseText;\n\t\t}\n\t\telse if (this.tagNameRegExp.test(token)) {\n\t\t\tthis.tempText += token;\n\t\t\treturn this.parseOpenTag;\n\t\t}\n\t\telse if (/\\s/.test(token)) {\n\t\t\tthis.stackTrace.push(new DOMElementNode(this.tempText));\n\t\t\tthis.tempText = '';\n\t\t\tthis.propType = 'attr';\n\t\t\treturn this.parsePropertyName;\n\t\t}\n\t}\n\n\tprivate parsePropertyName(token: string) {\n\t\tif (token === '>') {\n\t\t\tif (this.tempText.trim()) {\n\t\t\t\tthis.propertyName = this.tempText;\n\t\t\t\tthis.currentNode.addAttribute(this.propertyName, true);\n\t\t\t\tthis.propertyName, this.propertyValue = this.tempText = '';\n\t\t\t}\n\t\t\tif (isEmptyElement(this.currentNode.tagName)) {\n\t\t\t\tthis.popElement();\n\t\t\t}\n\t\t\tthis.tempText = '';\n\t\t\treturn this.parseText;\n\t\t}\n\t\telse if (token === '/') {\n\t\t\treturn this.parsePropertyName;\n\t\t}\n\t\telse if (/\\[/.test(token)) {\n\t\t\tthis.propType = 'input';\n\t\t\treturn this.parseInputOutput;\n\t\t}\n\t\telse if (/\\(|@/.test(token)) {\n\t\t\tthis.propType = 'output';\n\t\t\treturn this.parseInputOutput;\n\t\t}\n\t\telse if (/#/.test(token)) {\n\t\t\tthis.propType = 'ref-name';\n\t\t\treturn this.parseRefName;\n\t\t}\n\t\telse if (/=/.test(token)) {\n\t\t\tthis.propertyName = this.tempText;\n\t\t\tthis.tempText = '';\n\t\t\treturn this.parsePropertyName;\n\t\t} else if (/\"/.test(token)) {\n\t\t\treturn this.parsePropertyValue;\n\t\t} else if (/\\d/.test(token)) {\n\t\t\tthis.tempText += token;\n\t\t\treturn this.parsePropertyValue;\n\t\t}\n\t\telse if (/\\s/.test(token)) {\n\t\t\tif (this.tempText.trim()) {\n\t\t\t\tthis.propertyName = this.tempText;\n\t\t\t\tthis.currentNode.addAttribute(this.propertyName, true);\n\t\t\t\tthis.propertyName, this.propertyValue = this.tempText = '';\n\t\t\t}\n\t\t\treturn this.parsePropertyName;\n\t\t}\n\t\tthis.tempText += token;\n\t\treturn this.parsePropertyName;\n\t}\n\n\n\n\tprivate parseRefName(token: string) {\n\t\tif (/=/.test(token)) {\n\t\t\treturn this.parseRefName;\n\t\t}\n\t\telse if (/\"/.test(token)) {\n\t\t\tthis.propertyName = this.tempText;\n\t\t\tthis.tempText = '';\n\t\t\treturn this.parsePropertyValue;\n\t\t} else if (/\\s/.test(token)) {\n\t\t\tthis.currentNode.setTemplateRefName(this.tempText, '');\n\t\t\tthis.propertyName = this.tempText = '';\n\t\t\tthis.propType = 'attr';\n\t\t\treturn this.parsePropertyName;\n\t\t} else if (/>/.test(token)) {\n\t\t\tthis.currentNode.setTemplateRefName(this.tempText, '');\n\t\t\tthis.propertyName = this.tempText = '';\n\t\t\tthis.propType = 'attr';\n\t\t\treturn this.parseText;\n\t\t}\n\t\tthis.tempText += token;\n\t\treturn this.parseRefName;\n\t}\n\n\tprivate parseInputOutput(token: string) {\n\t\tif (/\\(/.test(token)) {\n\t\t\tthis.propType = 'two-way';\n\t\t\treturn this.parseInputOutput;\n\t\t}\n\t\telse if (/\\)|\\]|=/.test(token)) {\n\t\t\treturn this.parseInputOutput;\n\t\t}\n\t\telse if (/\"/.test(token)) {\n\t\t\tthis.propertyName = this.tempText;\n\t\t\tthis.tempText = '';\n\t\t\treturn this.parsePropertyValue;\n\t\t}\n\t\tthis.tempText += token;\n\t\treturn this.parseInputOutput;\n\t}\n\n\tprivate parsePropertyValue(token: string) {\n\t\tif (/\"/.test(token)) {\n\t\t\tthis.propertyValue = this.tempText;\n\t\t\tswitch (this.propType) {\n\t\t\t\tcase 'input':\n\t\t\t\t\tthis.currentNode.addInput(this.propertyName, this.propertyValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'output':\n\t\t\t\t\tthis.currentNode.addOutput(this.propertyName, this.propertyValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'two-way':\n\t\t\t\t\tthis.currentNode.addTwoWayBinding(this.propertyName, this.propertyValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ref-name':\n\t\t\t\t\tthis.currentNode.setTemplateRefName(this.propertyName, this.propertyValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'attr':\n\t\t\t\tdefault:\n\t\t\t\t\tif (/^([-+]?\\d*\\.?\\d+)(?:[eE]([-+]?\\d+))?$/.test(this.propertyValue.trim())) {\n\t\t\t\t\t\tthis.currentNode.addAttribute(this.propertyName, +this.propertyValue.trim());\n\t\t\t\t\t} else if (/^(true|false)$/.test(this.propertyValue.trim().toLowerCase())) {\n\t\t\t\t\t\tif (this.propertyValue.trim().toLowerCase() === 'true') {\n\t\t\t\t\t\t\tthis.currentNode.addAttribute(this.propertyName, true);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.currentNode.addAttribute(this.propertyName, false);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis.currentNode.addAttribute(this.propertyName, this.propertyValue);\n\t\t\t\t\t}\n\t\t\t}\n\t\t\tthis.propertyName, this.propertyValue = this.tempText = '';\n\t\t\tthis.propType = 'attr';\n\t\t\treturn this.parsePropertyName;\n\t\t}\n\t\tthis.tempText += token;\n\t\treturn this.parsePropertyValue;\n\t}\n\n\n\tprivate popElement() {\n\t\tconst element = this.stackTrace.pop();\n\t\tif (element) {\n\t\t\tconst parent = this.stackTrace.pop();\n\t\t\tif (parent && parent instanceof DOMElementNode) {\n\t\t\t\tif (typeof element === 'string') {\n\t\t\t\t\tparent.addTextChild(element);\n\t\t\t\t} else if (element instanceof DOMElementNode) {\n\t\t\t\t\tparent.addChild(this.checkNode(element));\n\t\t\t\t} else {\n\t\t\t\t\tparent.addChild(element);\n\t\t\t\t}\n\t\t\t\tthis.stackTrace.push(parent);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (typeof element === 'string') {\n\t\t\t\t\tparseTextChild(element).forEach(text => this.childStack.push(text));\n\t\t\t\t} else if (element instanceof DOMElementNode) {\n\t\t\t\t\tthis.childStack.push(this.checkNode(element));\n\t\t\t\t} else {\n\t\t\t\t\tthis.childStack.push(element);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcheckNode(node: DOMElementNode): DOMElementNode | DOMDirectiveNode {\n\t\tconst attributes = node.attributes;\n\t\tif (attributes) {\n\t\t\tlet temp: ElementAttribute<string, any> | ElementAttribute<string, any>[] | undefined = attributes.find(attr => attr.name === 'is');\n\t\t\tif (temp) {\n\t\t\t\tattributes.splice(attributes.indexOf(temp), 1);\n\t\t\t\tnode.is = temp.value as string;\n\t\t\t}\n\t\t\ttemp = attributes.filter(attr => {\n\t\t\t\treturn typeof attr.value === 'string' && (/\\{\\{(.+)\\}\\}/g).test(attr.value);\n\t\t\t});\n\t\t\tif (temp?.length) {\n\t\t\t\ttemp.forEach(templateAttrs => {\n\t\t\t\t\tattributes.splice(attributes.indexOf(templateAttrs), 1);\n\t\t\t\t\tnode.addTemplateAttr(templateAttrs.name, templateAttrs.value as string);\n\t\t\t\t});\n\t\t\t}\n\t\t\ttemp = attributes.filter(attr => attr.name.startsWith('on'));\n\t\t\tif (temp?.length) {\n\t\t\t\ttemp.forEach(templateAttrs => {\n\t\t\t\t\tattributes.splice(attributes.indexOf(templateAttrs), 1);\n\t\t\t\t\tnode.addOutput(templateAttrs.name.substring(2), templateAttrs.value as string);\n\t\t\t\t});\n\t\t\t}\n\t\t\ttemp = attributes.find(attr => attr.name.startsWith('*'));\n\t\t\tif (temp) {\n\t\t\t\tattributes.splice(attributes.indexOf(temp), 1);\n\t\t\t\tconst isTemplate = node.tagName === 'template';\n\t\t\t\tconst directiveNode = isTemplate ? new DOMFragmentNode(node.children) : node;\n\t\t\t\tconst directive = new DOMDirectiveNode(temp.name, temp.value as string ?? '', directiveNode);\n\t\t\t\tconst directiveName = temp.name.substring(1);\n\t\t\t\tif (isTemplate) {\n\t\t\t\t\tdirective.inputs = node.inputs;\n\t\t\t\t\tdirective.outputs = node.outputs;\n\t\t\t\t\tdirective.attributes = node.attributes;\n\t\t\t\t\tdirective.templateAttrs = node.templateAttrs;\n\t\t\t\t} else if (directiveRegistry.hasAttributes(directiveName)) {\n\t\t\t\t\tthis.extractDirectiveAttributesFromNode(directiveName, directive, node);\n\t\t\t\t}\n\t\t\t\treturn directive;\n\t\t\t}\n\t\t\tif (directiveRegistry.has(node.tagName)) {\n\t\t\t\t// try to find expression attribute\n\t\t\t\t// <if expression=\"a === b\">text child<div>...</div></if>\n\t\t\t\ttemp = attributes.find(attr => attr.name === 'expression');\n\t\t\t\tif (temp) {\n\t\t\t\t\tattributes.splice(attributes.indexOf(temp as ElementAttribute<string, string | number | boolean | object>), 1);\n\t\t\t\t}\n\t\t\t\tconst directiveNode = new DOMFragmentNode(node.children);\n\t\t\t\tconst directive = new DOMDirectiveNode('*' + node.tagName, temp?.value as string ?? '', directiveNode);\n\t\t\t\tthis.extractDirectiveAttributesFromNode(node.tagName, directive, node);\n\t\t\t\treturn directive;\n\t\t\t}\n\t\t} else if (directiveRegistry.has(node.tagName)) {\n\t\t\t// support structural directives without expression property\n\t\t\t// <add-note >text</add-note>\n\t\t\treturn new DOMDirectiveNode('*' + node.tagName, '', new DOMFragmentNode(node.children));\n\t\t}\n\t\treturn node;\n\t}\n\n\n\tprivate extractDirectiveAttributesFromNode(directiveName: string, directive: DOMDirectiveNode, node: DOMElementNode) {\n\t\tconst attributes = directiveRegistry.getAttributes(directiveName)!;\n\t\tconst filterByAttrName = createFilterByAttrName(attributes);\n\t\tdirective.inputs = node.inputs?.filter(filterByAttrName);\n\t\tdirective.outputs = node.outputs?.filter(filterByAttrName);\n\t\tdirective.twoWayBinding = node.twoWayBinding?.filter(filterByAttrName);\n\t\tdirective.attributes = node.attributes?.filter(filterByAttrName);\n\t\tdirective.templateAttrs = node.templateAttrs?.filter(filterByAttrName);\n\n\t\tnode.inputs && directive.inputs?.forEach(createArrayCleaner(node.inputs));\n\t\tnode.outputs && directive.outputs?.forEach(createArrayCleaner(node.outputs));\n\t\tnode.twoWayBinding && directive.twoWayBinding?.forEach(createArrayCleaner(node.twoWayBinding));\n\t\tnode.attributes && directive.attributes?.forEach(createArrayCleaner(node.attributes));\n\t\tnode.templateAttrs && directive.templateAttrs?.forEach(createArrayCleaner(node.templateAttrs));\n\t}\n}\n\nfunction createFilterByAttrName(attributes: string[]) {\n\treturn (attr: Attribute<string, any>) => attributes.includes(attr.name);\n}\n\nfunction createArrayCleaner(attributes: Attribute<string, any>[]) {\n\treturn (attr: Attribute<string, any>) => attributes.splice(attributes.indexOf(attr), 1);\n}\n\nexport class HTMLParser {\n\n\tnodeParser = new NodeParser();\n\n\tparse(html: string): DOMChild[] {\n\t\treturn this.nodeParser.parse(html);\n\t}\n\n\ttoDomRootNode(html: string): DOMNode {\n\t\tlet stack = this.nodeParser.parse(html);\n\t\tif (!stack || stack.length === 0) {\n\t\t\treturn new DOMFragmentNode([new TextContent('')]);\n\t\t} else if (stack?.length === 1) {\n\t\t\treturn stack[0];\n\t\t} else {\n\t\t\treturn new DOMFragmentNode(stack);\n\t\t}\n\t}\n\n\tstringify(stack: DOMNode[]) {\n\t\tlet html = '';\n\t\tstack?.forEach(node => {\n\t\t\tif (node instanceof TextContent) {\n\t\t\t\thtml += node.value;\n\t\t\t} else if (node instanceof LiveTextContent) {\n\t\t\t\thtml += `{{${node.value}}}`;\n\t\t\t} else if (node instanceof CommentNode) {\n\t\t\t\thtml += `<!-- ${node.comment} -->`;\n\t\t\t} else if (node instanceof DOMElementNode) {\n\t\t\t\tlet attrs = '';\n\t\t\t\tif (node.attributes) {\n\t\t\t\t\tattrs += node.attributes.map(attr => `${attr.name}=\"${attr.value}\"`).join(' ') + ' ';\n\t\t\t\t}\n\t\t\t\tif (node.twoWayBinding) {\n\t\t\t\t\tattrs += node.twoWayBinding.map(attr => `[(${attr.name})]=\"${attr.value}\"`).join(' ').concat(' ');\n\t\t\t\t}\n\t\t\t\tif (node.inputs) {\n\t\t\t\t\tattrs += node.inputs.map(attr => `[${attr.name}]=\"${attr.value}\"`).join(' ').concat(' ');\n\t\t\t\t}\n\t\t\t\tif (node.outputs) {\n\t\t\t\t\tattrs += node.outputs.map(attr => `(${attr.name})=\"${attr.value}\"`).join(' ').concat(' ');\n\t\t\t\t}\n\t\t\t\tif (node.templateAttrs) {\n\t\t\t\t\tattrs += node.templateAttrs.map(attr => `${attr.name}=\"${attr.value}\"`).join(' ').concat(' ');\n\t\t\t\t}\n\t\t\t\tif (isEmptyElement(node.tagName)) {\n\t\t\t\t\tif (attrs) {\n\t\t\t\t\t\thtml += `<${node.tagName} ${attrs}/>`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\thtml += `<${node.tagName} />`;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlet children = this.stringify(node.children);\n\t\t\t\t\tif (attrs && children) {\n\t\t\t\t\t\thtml += `<${node.tagName} ${attrs}>${children}</${node.tagName}>`;\n\t\t\t\t\t}\n\t\t\t\t\telse if (attrs) {\n\t\t\t\t\t\thtml += `<${node.tagName} ${attrs}></${node.tagName}>`;\n\t\t\t\t\t} else if (children) {\n\t\t\t\t\t\thtml += `<${node.tagName}>${children}<</${node.tagName}>`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\thtml += `<${node.tagName}></${node.tagName}>`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn html;\n\t}\n\n}\n\nexport const htmlParser = new HTMLParser();\n\n"]}
1
+ {"version":3,"file":"html-parser.js","sourceRoot":"","sources":["../../../src/elements/node/html-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACN,cAAc,EAAE,WAAW,EAAE,cAAc,EAC3C,WAAW,EAAE,eAAe,EAAE,eAAe,EAC7C,0BAA0B,EACG,yBAAyB,EACtD,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAMxE,MAAM,OAAO,mBAAmB;IAW/B;QACC,M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,MAAM,IAAI,CAAC,OAAO,GAAG,CAAC;qBAC1D;yBAAM;wBACN,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,MAAM,IAAI,CAAC,OAAO,GAAG,CAAC;qBAC9C;iBACD;aACD;QACF,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACb,CAAC;CAED;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC","sourcesContent":["import { isEmptyElement } from '../attributes/tags.js';\nimport {\n\tDomElementNode, CommentNode, parseTextChild,\n\tTextContent, LiveTextContent, DomFragmentNode,\n\tDomStructuralDirectiveNode, DomNode, DomChild,\n\tElementAttribute, Attribute, DomAttributeDirectiveNode, BaseNode\n} from '../ast/dom.js';\nimport { directiveRegistry } from '../directives/register-directive.js';\n\ntype Token = (token: string) => Token;\n\ntype ChildNode = DomElementNode | CommentNode | string;\n\nexport class EscapeHTMLCharacter {\n\tstatic ESCAPE_MAP: { [key: string]: string } = {\n\t\t'&amp;': '&',\n\t\t'&lt;': '<',\n\t\t'&gt;': '>',\n\t\t'&quot;': '\"',\n\t\t'&#x27;': \"'\",\n\t\t'&#x60;': '`'\n\t};\n\ttest: RegExp;\n\treplace: RegExp;\n\tconstructor() {\n\t\tconst escapeRegexSource = '(?:' + Object.keys(EscapeHTMLCharacter.ESCAPE_MAP).join('|') + ')';\n\t\tthis.test = new RegExp(escapeRegexSource);\n\t\tthis.replace = new RegExp(escapeRegexSource, 'g');\n\t}\n\n\tescaper(match: string): string {\n\t\treturn EscapeHTMLCharacter.ESCAPE_MAP[match];\n\t}\n\n\tunescape(text: string): string {\n\t\tif (!text) {\n\t\t\treturn text;\n\t\t}\n\t\treturn this.test.test(text) ? text.replace(this.replace, this.escaper) : text;\n\t}\n}\n\nexport class NodeParser {\n\n\tprivate index: number;\n\tprivate stateFn: Token;\n\n\tprivate tagNameRegExp = /[\\-\\.0-9_a-z\\xB7\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u037D\\u037F-\\u1FFF\\u200C\\u200D\\u203F\\u2040\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]|[\\uD800-\\uDB7F][\\uDC00-\\uDFFF]/;\n\n\tprivate childStack: DomChild[];\n\tprivate stackTrace: ChildNode[];\n\n\tprivate get currentNode(): DomElementNode {\n\t\treturn this.stackTrace[this.stackTrace.length - 1] as DomElementNode;\n\t}\n\n\tprivate commentOpenCount = 0;\n\tprivate commentCloseCount = 0;\n\n\tprivate tempText: string;\n\n\tprivate propertyName: string;\n\tprivate propertyValue: string;\n\tprivate propType: 'attr' | 'ref-name' | 'input' | 'output' | 'two-way';\n\n\tprivate escaper = new EscapeHTMLCharacter();\n\n\tparse(html: string)/*: DomNode*/ {\n\t\tthis.reset();\n\t\tfor (; this.index < html.length; this.index++) {\n\t\t\tthis.stateFn = this.stateFn(html[this.index]);\n\t\t}\n\t\tif (this.tempText && this.stateFn === this.parseText) {\n\t\t\tthis.stateFn('<');\n\t\t}\n\t\tif (this.stackTrace.length > 0) {\n\t\t\tconsole.error(this.stackTrace);\n\t\t\tthrow new Error(`error parsing html, had ${this.stackTrace.length} element, with no closing tag`);\n\t\t}\n\t\tlet stack = this.childStack;\n\t\tthis.reset();\n\t\treturn stack;\n\t}\n\n\tprivate reset() {\n\t\tthis.index = 0;\n\t\tthis.childStack = [];\n\t\tthis.stackTrace = [];\n\t\tthis.propType = 'attr';\n\t\tthis.commentOpenCount = 0;\n\t\tthis.commentCloseCount = 0;\n\t\tthis.stateFn = this.parseText;\n\t\tthis.propertyName = this.propertyValue = this.tempText = '';\n\t}\n\n\tprivate parseText(token: string) {\n\t\tif (token === '<') {\n\t\t\tif (this.tempText) {\n\t\t\t\tthis.tempText = this.escaper.unescape(this.tempText);\n\t\t\t\tthis.stackTrace.push(this.tempText);\n\t\t\t\tthis.popElement();\n\t\t\t\tthis.tempText = '';\n\t\t\t}\n\t\t\treturn this.parseTag;\n\t\t}\n\t\tthis.tempText += token;\n\t\treturn this.parseText;\n\t}\n\n\tprivate parseTag(token: string) {\n\t\tif (token === '/') {\n\t\t\treturn this.parseCloseTag;\n\t\t}\n\t\tif (token === '!') {\n\t\t\tthis.commentOpenCount = 0;\n\t\t\tthis.commentCloseCount = 0;\n\t\t\treturn this.parseComment;\n\t\t}\n\t\tthis.index--;\n\t\treturn this.parseOpenTag;\n\t}\n\n\tprivate parseComment(token: string) {\n\t\tif (token === '-') {\n\t\t\tif (this.commentOpenCount < 2) {\n\t\t\t\tthis.commentOpenCount++;\n\t\t\t} else {\n\t\t\t\tthis.commentCloseCount++;\n\t\t\t}\n\t\t\treturn this.parseComment;\n\t\t}\n\t\telse if (token === '>' && this.commentCloseCount === 2) {\n\t\t\tthis.tempText = this.escaper.unescape(this.tempText);\n\t\t\tthis.stackTrace.push(new CommentNode(this.tempText.trim()));\n\t\t\tthis.popElement();\n\t\t\tthis.tempText = '';\n\t\t\tthis.commentOpenCount = 0;\n\t\t\tthis.commentCloseCount = 0;\n\t\t\treturn this.parseText;\n\t\t}\n\t\tif (this.commentCloseCount > 0) {\n\t\t\tfor (let i = 0; i < this.commentCloseCount; i++) {\n\t\t\t\tthis.tempText += '-';\n\t\t\t}\n\t\t\tthis.commentCloseCount = 0;\n\t\t}\n\t\tthis.tempText += token;\n\t\treturn this.parseComment;\n\t}\n\n\tprivate parseCloseTag(token: string) {\n\t\tif (token === '>') {\n\t\t\tif (!isEmptyElement(this.currentNode.tagName)\n\t\t\t\t&& this.currentNode.tagName.trim().toLowerCase() !== this.tempText.trim().toLowerCase()\n\t\t\t) {\n\t\t\t\tthrow 'Wrong closed tag at char ' + this.index;\n\t\t\t}\n\t\t\tthis.popElement();\n\t\t\tthis.tempText = '';\n\t\t\treturn this.parseText;\n\t\t}\n\t\tthis.tempText += token;\n\t\treturn this.parseCloseTag;\n\t}\n\n\tprivate parseOpenTag(token: string) {\n\t\tif (token === '>') {\n\t\t\tthis.stackTrace.push(new DomElementNode(this.tempText));\n\t\t\tif (isEmptyElement(this.tempText)) {\n\t\t\t\tthis.popElement();\n\t\t\t}\n\t\t\tthis.tempText = '';\n\t\t\treturn this.parseText;\n\t\t}\n\t\telse if (this.tagNameRegExp.test(token)) {\n\t\t\tthis.tempText += token;\n\t\t\treturn this.parseOpenTag;\n\t\t}\n\t\telse if (/\\s/.test(token)) {\n\t\t\tthis.stackTrace.push(new DomElementNode(this.tempText));\n\t\t\tthis.tempText = '';\n\t\t\tthis.propType = 'attr';\n\t\t\treturn this.parsePropertyName;\n\t\t}\n\t}\n\n\tprivate parsePropertyName(token: string) {\n\t\tif (token === '>') {\n\t\t\tif (this.tempText.trim()) {\n\t\t\t\tthis.propertyName = this.tempText;\n\t\t\t\tthis.currentNode.addAttribute(this.propertyName, true);\n\t\t\t\tthis.propertyName, this.propertyValue = this.tempText = '';\n\t\t\t}\n\t\t\tif (isEmptyElement(this.currentNode.tagName)) {\n\t\t\t\tthis.popElement();\n\t\t\t}\n\t\t\tthis.tempText = '';\n\t\t\treturn this.parseText;\n\t\t}\n\t\telse if (token === '/') {\n\t\t\treturn this.parsePropertyName;\n\t\t}\n\t\telse if (/\\[/.test(token)) {\n\t\t\tthis.propType = 'input';\n\t\t\treturn this.parseInputOutput;\n\t\t}\n\t\telse if (/\\(|@/.test(token)) {\n\t\t\tthis.propType = 'output';\n\t\t\treturn this.parseInputOutput;\n\t\t}\n\t\telse if (/#/.test(token)) {\n\t\t\tthis.propType = 'ref-name';\n\t\t\treturn this.parseRefName;\n\t\t}\n\t\telse if (/=/.test(token)) {\n\t\t\tthis.propertyName = this.tempText;\n\t\t\tthis.tempText = '';\n\t\t\treturn this.parsePropertyName;\n\t\t} else if (/\"/.test(token)) {\n\t\t\treturn this.parsePropertyValue;\n\t\t} else if (/\\d/.test(token)) {\n\t\t\tthis.tempText += token;\n\t\t\treturn this.parsePropertyValue;\n\t\t}\n\t\telse if (/\\s/.test(token)) {\n\t\t\tif (this.tempText.trim()) {\n\t\t\t\tthis.propertyName = this.tempText;\n\t\t\t\tthis.currentNode.addAttribute(this.propertyName, true);\n\t\t\t\tthis.propertyName, this.propertyValue = this.tempText = '';\n\t\t\t}\n\t\t\treturn this.parsePropertyName;\n\t\t}\n\t\tthis.tempText += token;\n\t\treturn this.parsePropertyName;\n\t}\n\n\n\n\tprivate parseRefName(token: string) {\n\t\tif (/=/.test(token)) {\n\t\t\treturn this.parseRefName;\n\t\t}\n\t\telse if (/\"/.test(token)) {\n\t\t\tthis.propertyName = this.tempText;\n\t\t\tthis.tempText = '';\n\t\t\treturn this.parsePropertyValue;\n\t\t} else if (/\\s/.test(token)) {\n\t\t\tthis.currentNode.setTemplateRefName(this.tempText, '');\n\t\t\tthis.propertyName = this.tempText = '';\n\t\t\tthis.propType = 'attr';\n\t\t\treturn this.parsePropertyName;\n\t\t} else if (/>/.test(token)) {\n\t\t\tthis.currentNode.setTemplateRefName(this.tempText, '');\n\t\t\tthis.propertyName = this.tempText = '';\n\t\t\tthis.propType = 'attr';\n\t\t\treturn this.parseText;\n\t\t}\n\t\tthis.tempText += token;\n\t\treturn this.parseRefName;\n\t}\n\n\tprivate parseInputOutput(token: string) {\n\t\tif (/\\(/.test(token)) {\n\t\t\tthis.propType = 'two-way';\n\t\t\treturn this.parseInputOutput;\n\t\t}\n\t\telse if (/\\)|\\]|=/.test(token)) {\n\t\t\treturn this.parseInputOutput;\n\t\t}\n\t\telse if (/\"/.test(token)) {\n\t\t\tthis.propertyName = this.tempText;\n\t\t\tthis.tempText = '';\n\t\t\treturn this.parsePropertyValue;\n\t\t}\n\t\tthis.tempText += token;\n\t\treturn this.parseInputOutput;\n\t}\n\n\tprivate parsePropertyValue(token: string) {\n\t\tif (/\"/.test(token)) {\n\t\t\tthis.propertyValue = this.tempText;\n\t\t\tswitch (this.propType) {\n\t\t\t\tcase 'input':\n\t\t\t\t\tthis.currentNode.addInput(this.propertyName, this.propertyValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'output':\n\t\t\t\t\tthis.currentNode.addOutput(this.propertyName, this.propertyValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'two-way':\n\t\t\t\t\tthis.currentNode.addTwoWayBinding(this.propertyName, this.propertyValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ref-name':\n\t\t\t\t\tthis.currentNode.setTemplateRefName(this.propertyName, this.propertyValue);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'attr':\n\t\t\t\tdefault:\n\t\t\t\t\tif (/^([-+]?\\d*\\.?\\d+)(?:[eE]([-+]?\\d+))?$/.test(this.propertyValue.trim())) {\n\t\t\t\t\t\tthis.currentNode.addAttribute(this.propertyName, +this.propertyValue.trim());\n\t\t\t\t\t} else if (/^(true|false)$/.test(this.propertyValue.trim().toLowerCase())) {\n\t\t\t\t\t\tif (this.propertyValue.trim().toLowerCase() === 'true') {\n\t\t\t\t\t\t\tthis.currentNode.addAttribute(this.propertyName, true);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.currentNode.addAttribute(this.propertyName, false);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis.currentNode.addAttribute(this.propertyName, this.propertyValue);\n\t\t\t\t\t}\n\t\t\t}\n\t\t\tthis.propertyName, this.propertyValue = this.tempText = '';\n\t\t\tthis.propType = 'attr';\n\t\t\treturn this.parsePropertyName;\n\t\t}\n\t\tthis.tempText += token;\n\t\treturn this.parsePropertyValue;\n\t}\n\n\n\tprivate popElement() {\n\t\tconst element = this.stackTrace.pop();\n\t\tif (element) {\n\t\t\tconst parent = this.stackTrace.pop();\n\t\t\tif (parent && parent instanceof DomElementNode) {\n\t\t\t\tif (typeof element === 'string') {\n\t\t\t\t\tparent.addTextChild(element);\n\t\t\t\t} else if (element instanceof DomElementNode) {\n\t\t\t\t\tparent.addChild(this.checkNode(element));\n\t\t\t\t} else {\n\t\t\t\t\tparent.addChild(element);\n\t\t\t\t}\n\t\t\t\tthis.stackTrace.push(parent);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (typeof element === 'string') {\n\t\t\t\t\tparseTextChild(element).forEach(text => this.childStack.push(text));\n\t\t\t\t} else if (element instanceof DomElementNode) {\n\t\t\t\t\tthis.childStack.push(this.checkNode(element));\n\t\t\t\t} else {\n\t\t\t\t\tthis.childStack.push(element);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcheckNode(node: DomElementNode): DomElementNode | DomStructuralDirectiveNode {\n\t\tconst attributes = node.attributes;\n\t\tif (attributes) {\n\t\t\tlet temp: ElementAttribute<string, any> | ElementAttribute<string, any>[] | undefined;\n\n\t\t\ttemp = attributes.find(attr => attr.name === 'is');\n\t\t\tif (temp) {\n\t\t\t\tattributes.splice(attributes.indexOf(temp), 1);\n\t\t\t\tnode.is = temp.value as string;\n\t\t\t}\n\t\t\ttemp = attributes.filter(attr => {\n\t\t\t\treturn typeof attr.value === 'string' && (/\\{\\{(.+)\\}\\}/g).test(attr.value);\n\t\t\t});\n\t\t\tif (temp?.length) {\n\t\t\t\ttemp.forEach(templateAttrs => {\n\t\t\t\t\tattributes.splice(attributes.indexOf(templateAttrs), 1);\n\t\t\t\t\tnode.addTemplateAttr(templateAttrs.name, templateAttrs.value as string);\n\t\t\t\t});\n\t\t\t}\n\t\t\ttemp = attributes.filter(attr => attr.name.startsWith('on'));\n\t\t\tif (temp?.length) {\n\t\t\t\ttemp.forEach(templateAttrs => {\n\t\t\t\t\tattributes.splice(attributes.indexOf(templateAttrs), 1);\n\t\t\t\t\tnode.addOutput(templateAttrs.name.substring(2), templateAttrs.value as string);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst directiveNames = this.extractDirectiveNames(node);\n\t\tlet sdName: string | undefined;\n\t\tif (directiveNames.length) {\n\t\t\tconst directives: DomAttributeDirectiveNode[] = [];\n\t\t\tdirectiveNames.forEach(attributeName => {\n\t\t\t\tif (attributeName.startsWith('*')) {\n\t\t\t\t\tif (sdName) {\n\t\t\t\t\t\tconsole.error(`Only one Structural Directive is allowed on an element [${sdName}, ${attributeName}]`);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tsdName = attributeName;\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tconst directive = new DomAttributeDirectiveNode(attributeName);\n\t\t\t\tif (directiveRegistry.get(attributeName)!.hasAttributes()) {\n\t\t\t\t\tthis.extractDirectiveAttributesFromNode(attributeName, directive, node);\n\t\t\t\t}\n\t\t\t\tdirectives.push(directive);\n\t\t\t});\n\t\t\tif (directives.length) {\n\t\t\t\tnode.attributeDirectives = directives;\n\t\t\t}\n\t\t}\n\t\tif (sdName) {\n\t\t\t// <div *for [forOf]=\"array\" let-item [trackBy]=\"method\" let-i=\"index\" > {{item}} </div>\n\t\t\t// <div *for=\"let item of array; let i = index; trackBy=method;\" > {{item}} </div>\n\n\t\t\tconst temp = node.attributes!.filter(attr => attr.name == sdName)[0];\n\t\t\tnode.attributes!.splice(node.attributes!.indexOf(temp), 1);\n\t\t\tconst isTemplate = node.tagName === 'template';\n\n\t\t\tconst directiveNode = isTemplate ? new DomFragmentNode(node.children) : node;\n\t\t\tconst directive = (typeof temp?.value === 'boolean')\n\t\t\t\t? new DomStructuralDirectiveNode(temp.name, directiveNode)\n\t\t\t\t: new DomStructuralDirectiveNode(temp.name, directiveNode, String(temp.value));\n\t\t\tconst directiveName = temp.name.substring(1);\n\t\t\tif (isTemplate) {\n\t\t\t\tdirective.inputs = node.inputs;\n\t\t\t\tdirective.outputs = node.outputs;\n\t\t\t\tdirective.attributes = node.attributes;\n\t\t\t\tdirective.templateAttrs = node.templateAttrs;\n\t\t\t} else if (directiveRegistry.hasAttributes(directiveName)) {\n\t\t\t\tthis.extractDirectiveAttributesFromNode(directiveName, directive, node);\n\t\t\t}\n\t\t\treturn directive;\n\t\t}\n\n\t\treturn node;\n\t}\n\n\n\tprivate extractDirectiveAttributesFromNode(directiveName: string, directive: BaseNode, node: DomElementNode): void {\n\t\tconst attributes = directiveRegistry.getAttributes(directiveName);\n\t\tif (!attributes) {\n\t\t\treturn;\n\t\t}\n\t\tconst filterByAttrName = createFilterByAttrName(attributes);\n\t\tdirective.attributes = node.attributes?.filter(filterByAttrName);\n\t\tdirective.inputs = node.inputs?.filter(filterByAttrName);\n\t\tdirective.outputs = node.outputs?.filter(filterByAttrName);\n\t\tdirective.twoWayBinding = node.twoWayBinding?.filter(filterByAttrName);\n\t\tdirective.templateAttrs = node.templateAttrs?.filter(filterByAttrName);\n\n\t\tnode.inputs && directive.inputs?.forEach(createArrayCleaner(node.inputs));\n\t\tnode.outputs && directive.outputs?.forEach(createArrayCleaner(node.outputs));\n\t\tnode.twoWayBinding && directive.twoWayBinding?.forEach(createArrayCleaner(node.twoWayBinding));\n\t\tnode.attributes && directive.attributes?.forEach(createArrayCleaner(node.attributes));\n\t\tnode.templateAttrs && directive.templateAttrs?.forEach(createArrayCleaner(node.templateAttrs));\n\t}\n\tprivate extractDirectiveNames(node: BaseNode): string[] {\n\t\tconst names: string[] = [];\n\t\tif (node.attributes?.length) {\n\t\t\tnames.push(...this.getAttributeDirectives(node.attributes));\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnames.push(...this.getAttributeDirectives(node.inputs));\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnames.push(...this.getAttributeDirectives(node.twoWayBinding));\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnames.push(...this.getAttributeDirectives(node.templateAttrs));\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnames.push(...this.getAttributeDirectives(node.outputs));\n\t\t}\n\t\treturn names;\n\t}\n\tprivate getAttributeDirectives(attributes: Attribute<string, any>[]): string[] {\n\t\treturn directiveRegistry.filterDirectives(attributes.map(attr => attr.name));\n\t}\n}\n\nfunction createFilterByAttrName(attributes: string[]) {\n\treturn (attr: Attribute<string, any>) => attributes.includes(attr.name);\n}\n\nfunction createArrayCleaner(attributes: Attribute<string, any>[]) {\n\treturn (attr: Attribute<string, any>) => attributes.splice(attributes.indexOf(attr), 1);\n}\n\nexport class HTMLParser {\n\n\tnodeParser = new NodeParser();\n\n\tparse(html: string): DomChild[] {\n\t\treturn this.nodeParser.parse(html);\n\t}\n\n\ttoDomRootNode(html: string): DomNode {\n\t\tlet stack = this.nodeParser.parse(html);\n\t\tif (!stack || stack.length === 0) {\n\t\t\treturn new DomFragmentNode([new TextContent('')]);\n\t\t} else if (stack?.length === 1) {\n\t\t\treturn stack[0];\n\t\t} else {\n\t\t\treturn new DomFragmentNode(stack);\n\t\t}\n\t}\n\n\tstringify(stack?: DomNode[]) {\n\t\tlet html = '';\n\t\tstack?.forEach(node => {\n\t\t\tif (node instanceof TextContent) {\n\t\t\t\thtml += node.value;\n\t\t\t} else if (node instanceof LiveTextContent) {\n\t\t\t\thtml += `{{${node.value}}}`;\n\t\t\t} else if (node instanceof CommentNode) {\n\t\t\t\thtml += `<!-- ${node.comment} -->`;\n\t\t\t} else if (node instanceof DomElementNode) {\n\t\t\t\tlet attrs = '';\n\t\t\t\tif (node.attributes) {\n\t\t\t\t\tattrs += node.attributes.map(attr => `${attr.name}=\"${attr.value}\"`).join(' ') + ' ';\n\t\t\t\t}\n\t\t\t\tif (node.twoWayBinding) {\n\t\t\t\t\tattrs += node.twoWayBinding.map(attr => `[(${attr.name})]=\"${attr.value}\"`).join(' ').concat(' ');\n\t\t\t\t}\n\t\t\t\tif (node.inputs) {\n\t\t\t\t\tattrs += node.inputs.map(attr => `[${attr.name}]=\"${attr.value}\"`).join(' ').concat(' ');\n\t\t\t\t}\n\t\t\t\tif (node.outputs) {\n\t\t\t\t\tattrs += node.outputs.map(attr => `(${attr.name})=\"${attr.value}\"`).join(' ').concat(' ');\n\t\t\t\t}\n\t\t\t\tif (node.templateAttrs) {\n\t\t\t\t\tattrs += node.templateAttrs.map(attr => `${attr.name}=\"${attr.value}\"`).join(' ').concat(' ');\n\t\t\t\t}\n\t\t\t\tif (isEmptyElement(node.tagName)) {\n\t\t\t\t\tif (attrs) {\n\t\t\t\t\t\thtml += `<${node.tagName} ${attrs}/>`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\thtml += `<${node.tagName} />`;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlet children = this.stringify(node.children);\n\t\t\t\t\tif (attrs && children) {\n\t\t\t\t\t\thtml += `<${node.tagName} ${attrs}>${children}</${node.tagName}>`;\n\t\t\t\t\t}\n\t\t\t\t\telse if (attrs) {\n\t\t\t\t\t\thtml += `<${node.tagName} ${attrs}></${node.tagName}>`;\n\t\t\t\t\t} else if (children) {\n\t\t\t\t\t\thtml += `<${node.tagName}>${children}<</${node.tagName}>`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\thtml += `<${node.tagName}></${node.tagName}>`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn html;\n\t}\n\n}\n\nexport const htmlParser = new HTMLParser();\n\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibyar/elements",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "Aurora element, hold info about HTMLElements class, attributes and tag name",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/ibyar/aurora/tree/dev/packages/elements",
@@ -23,7 +23,7 @@
23
23
  "access": "public"
24
24
  },
25
25
  "devDependencies": {
26
- "typescript": "^4.4.4"
26
+ "typescript": "^4.5.2"
27
27
  },
28
28
  "scripts": {
29
29
  "build": "tsc --build --verbose"
@@ -34,5 +34,5 @@
34
34
  "elements-info",
35
35
  "typescript"
36
36
  ],
37
- "gitHead": "b7bef2ea5defbd3ec18eddf13a07330e04e65708"
37
+ "gitHead": "2b67ab6bafaaf8bf796c2a5de13d745034381dfb"
38
38
  }
@@ -1,7 +1,7 @@
1
- import { DOMNode, CommentNode, DOMElementNode, TextContent } from '../ast/dom.js';
1
+ import { DomNode, CommentNode, DomElementNode, TextContent } from '../ast/dom.js';
2
2
  export declare class TemplateParser {
3
- parse(template: HTMLTemplateElement): DOMNode;
4
- createComponent(child: ChildNode): CommentNode | DOMElementNode | (TextContent | import("../ast/dom.js").LiveTextContent)[];
5
- toDomRenderRootNode<T>(template: DOMNode | HTMLTemplateElement | string): (model: T) => string | HTMLTemplateElement | DOMNode;
3
+ parse(template: HTMLTemplateElement): DomNode;
4
+ createComponent(child: ChildNode): CommentNode | DomElementNode | (TextContent | import("../ast/dom.js").LiveTextContent)[];
5
+ toDomRenderRootNode<T>(template: DomNode | HTMLTemplateElement | string): (model: T) => string | HTMLTemplateElement | DomNode;
6
6
  }
7
7
  export declare const templateParser: TemplateParser;
@@ -1,14 +1,14 @@
1
- import { CommentNode, DOMElementNode, DOMFragmentNode, parseTextChild, TextContent } from '../ast/dom.js';
1
+ import { CommentNode, DomElementNode, DomFragmentNode, parseTextChild, TextContent } from '../ast/dom.js';
2
2
  import { NodeFactory } from '../ast/factory.js';
3
3
  export class TemplateParser {
4
4
  parse(template) {
5
5
  if (template.content.childNodes.length == 0) {
6
- return new DOMFragmentNode([new TextContent('')]);
6
+ return new DomFragmentNode([new TextContent('')]);
7
7
  }
8
8
  else if (template.content.childNodes.length === 1) {
9
9
  let node = this.createComponent(template.content.firstChild);
10
10
  if (Array.isArray(node)) {
11
- return new DOMFragmentNode(node);
11
+ return new DomFragmentNode(node);
12
12
  }
13
13
  else {
14
14
  return node;
@@ -25,7 +25,7 @@ export class TemplateParser {
25
25
  return [toFlat];
26
26
  }
27
27
  });
28
- return new DOMFragmentNode(children);
28
+ return new DomFragmentNode(children);
29
29
  }
30
30
  }
31
31
  createComponent(child) {
@@ -37,7 +37,7 @@ export class TemplateParser {
37
37
  }
38
38
  else {
39
39
  const element = child;
40
- const node = new DOMElementNode(element.tagName.toLowerCase(), element.attributes.getNamedItem('is')?.value);
40
+ const node = new DomElementNode(element.tagName.toLowerCase(), element.attributes.getNamedItem('is')?.value);
41
41
  for (let i = 0; i < element.attributes.length; i++) {
42
42
  const attr = element.attributes.item(i);
43
43
  NodeFactory.handelAttribute(node, attr.name, attr.value);
@@ -1 +1 @@
1
- {"version":3,"file":"template-parser.js","sourceRoot":"","sources":["../../../src/elements/template/template-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EACa,WAAW,EAC9B,cAAc,EAAE,eAAe,EAC/B,cAAc,EAAE,WAAW,EAC3B,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,OAAO,cAAc;IAE1B,KAAK,CAAC,QAA6B;QAClC,IAAI,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,IAAI,CAAC,EAAE;YAC5C,OAAO,IAAI,eAAe,CAAC,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAClD;aAAM,IAAI,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YACpD,IAAI,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAuB,CAAC,CAAC;YAC1E,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACxB,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;aACjC;iBAAM;gBACN,OAAO,IAAI,CAAC;aACZ;SACD;aAAuD;YACvD,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;iBACtE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;iBACvC,OAAO,CAAC,UAAU,MAAM;gBACxB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;oBAC1B,OAAO,MAAM,CAAC;iBACd;qBAAM;oBACN,OAAO,CAAC,MAAM,CAAC,CAAC;iBAChB;YACF,CAAC,CAAC,CAA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,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;iBACrB;YACF,CAAC,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;SACZ;IACF,CAAC;IAED,mBAAmB,CAAI,QAAgD;QACtE,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YACjC,IAAI,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAC9C,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;YAC1B,QAAQ,GAAG,IAAI,CAAC;SAChB;aAAM,IAAI,QAAQ,YAAY,mBAAmB,EAAE;YACnD,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SAChC;QACD,OAAO,CAAC,CAAC,KAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACD;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC","sourcesContent":["import {\n\tDOMChild, DOMNode, CommentNode,\n\tDOMElementNode, DOMFragmentNode,\n\tparseTextChild, TextContent\n} from '../ast/dom.js';\n\nimport { NodeFactory } from '../ast/factory.js';\n\n\nexport class TemplateParser {\n\n\tparse(template: HTMLTemplateElement): DOMNode {\n\t\tif (template.content.childNodes.length == 0) {\n\t\t\treturn new DOMFragmentNode([new TextContent('')]);\n\t\t} else if (template.content.childNodes.length === 1) {\n\t\t\tlet node = this.createComponent(template.content.firstChild as ChildNode);\n\t\t\tif (Array.isArray(node)) {\n\t\t\t\treturn new DOMFragmentNode(node);\n\t\t\t} else {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t} else /* if (template.content.childNodes.length > 1)*/ {\n\t\t\tconst children = Array.prototype.slice.call(template.content.childNodes)\n\t\t\t\t.map(item => this.createComponent(item))\n\t\t\t\t.flatMap(function (toFlat): DOMChild[] {\n\t\t\t\t\tif (Array.isArray(toFlat)) {\n\t\t\t\t\t\treturn toFlat;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn [toFlat];\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\treturn new DOMFragmentNode(children);\n\t\t}\n\t}\n\n\tcreateComponent(child: ChildNode) {\n\t\tif (child instanceof Text) {\n\t\t\treturn parseTextChild(child.textContent || '');\n\t\t} else if (child instanceof Comment) {\n\t\t\treturn new CommentNode(child.textContent || '');\n\t\t} else {\n\t\t\t/**\n\t\t\t * can't detect directives in template, as '*' not allowed as qualified attribute name\n\t\t\t * also all attributes names will be 'lower case'\n\t\t\t */\n\t\t\tconst element: HTMLElement = child as HTMLElement;\n\t\t\tconst node = new DOMElementNode(element.tagName.toLowerCase(), element.attributes.getNamedItem('is')?.value);\n\t\t\tfor (let i = 0; i < element.attributes.length; i++) {\n\t\t\t\tconst attr = element.attributes.item(i) as Attr;\n\t\t\t\tNodeFactory.handelAttribute(node, attr.name, attr.value);\n\t\t\t}\n\t\t\tconst children = Array.prototype.slice.call(element.childNodes)\n\t\t\t\t.map(item => this.createComponent(item));\n\t\t\tchildren.forEach(child => {\n\t\t\t\tif (Array.isArray(child)) {\n\t\t\t\t\tchild.forEach(text => node.addChild(text));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tnode.addChild(child);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn node;\n\t\t}\n\t}\n\n\ttoDomRenderRootNode<T>(template: DOMNode | HTMLTemplateElement | string) {\n\t\tif (typeof template === 'string') {\n\t\t\tlet temp = document.createElement('template');\n\t\t\ttemp.innerHTML = template;\n\t\t\ttemplate = temp;\n\t\t} else if (template instanceof HTMLTemplateElement) {\n\t\t\ttemplate = this.parse(template);\n\t\t}\n\t\treturn ((model: T) => template);\n\t}\n}\n\nexport const templateParser = new TemplateParser();\n\n"]}
1
+ {"version":3,"file":"template-parser.js","sourceRoot":"","sources":["../../../src/elements/template/template-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EACa,WAAW,EAC9B,cAAc,EAAE,eAAe,EAC/B,cAAc,EAAE,WAAW,EAC3B,M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UAAU,CAAC,CAAC;YAC9C,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;YAC1B,QAAQ,GAAG,IAAI,CAAC;SAChB;aAAM,IAAI,QAAQ,YAAY,mBAAmB,EAAE;YACnD,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SAChC;QACD,OAAO,CAAC,CAAC,KAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;CACD;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC","sourcesContent":["import {\n\tDomChild, DomNode, CommentNode,\n\tDomElementNode, DomFragmentNode,\n\tparseTextChild, TextContent\n} from '../ast/dom.js';\n\nimport { NodeFactory } from '../ast/factory.js';\n\n\nexport class TemplateParser {\n\n\tparse(template: HTMLTemplateElement): DomNode {\n\t\tif (template.content.childNodes.length == 0) {\n\t\t\treturn new DomFragmentNode([new TextContent('')]);\n\t\t} else if (template.content.childNodes.length === 1) {\n\t\t\tlet node = this.createComponent(template.content.firstChild as ChildNode);\n\t\t\tif (Array.isArray(node)) {\n\t\t\t\treturn new DomFragmentNode(node);\n\t\t\t} else {\n\t\t\t\treturn node;\n\t\t\t}\n\t\t} else /* if (template.content.childNodes.length > 1)*/ {\n\t\t\tconst children = Array.prototype.slice.call(template.content.childNodes)\n\t\t\t\t.map(item => this.createComponent(item))\n\t\t\t\t.flatMap(function (toFlat): DomChild[] {\n\t\t\t\t\tif (Array.isArray(toFlat)) {\n\t\t\t\t\t\treturn toFlat;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn [toFlat];\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\treturn new DomFragmentNode(children);\n\t\t}\n\t}\n\n\tcreateComponent(child: ChildNode) {\n\t\tif (child instanceof Text) {\n\t\t\treturn parseTextChild(child.textContent || '');\n\t\t} else if (child instanceof Comment) {\n\t\t\treturn new CommentNode(child.textContent || '');\n\t\t} else {\n\t\t\t/**\n\t\t\t * can't detect directives in template, as '*' not allowed as qualified attribute name\n\t\t\t * also all attributes names will be 'lower case'\n\t\t\t */\n\t\t\tconst element: HTMLElement = child as HTMLElement;\n\t\t\tconst node = new DomElementNode(element.tagName.toLowerCase(), element.attributes.getNamedItem('is')?.value);\n\t\t\tfor (let i = 0; i < element.attributes.length; i++) {\n\t\t\t\tconst attr = element.attributes.item(i) as Attr;\n\t\t\t\tNodeFactory.handelAttribute(node, attr.name, attr.value);\n\t\t\t}\n\t\t\tconst children = Array.prototype.slice.call(element.childNodes)\n\t\t\t\t.map(item => this.createComponent(item));\n\t\t\tchildren.forEach(child => {\n\t\t\t\tif (Array.isArray(child)) {\n\t\t\t\t\tchild.forEach(text => node.addChild(text));\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tnode.addChild(child);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn node;\n\t\t}\n\t}\n\n\ttoDomRenderRootNode<T>(template: DomNode | HTMLTemplateElement | string) {\n\t\tif (typeof template === 'string') {\n\t\t\tlet temp = document.createElement('template');\n\t\t\ttemp.innerHTML = template;\n\t\t\ttemplate = temp;\n\t\t} else if (template instanceof HTMLTemplateElement) {\n\t\t\ttemplate = this.parse(template);\n\t\t}\n\t\treturn ((model: T) => template);\n\t}\n}\n\nexport const templateParser = new TemplateParser();\n\n"]}