@lwc/template-compiler 2.6.2 → 2.7.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/dist/commonjs/codegen/codegen.js +73 -3
- package/dist/commonjs/codegen/codegen.js.map +1 -1
- package/dist/commonjs/codegen/helpers.js +34 -20
- package/dist/commonjs/codegen/helpers.js.map +1 -1
- package/dist/commonjs/codegen/index.js +183 -192
- package/dist/commonjs/codegen/index.js.map +1 -1
- package/dist/commonjs/index.js +12 -5
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/parser/attribute.js +12 -4
- package/dist/commonjs/parser/attribute.js.map +1 -1
- package/dist/commonjs/parser/constants.js +20 -7
- package/dist/commonjs/parser/constants.js.map +1 -1
- package/dist/commonjs/parser/expression.js +5 -2
- package/dist/commonjs/parser/expression.js.map +1 -1
- package/dist/commonjs/parser/html.js +2 -1
- package/dist/commonjs/parser/html.js.map +1 -1
- package/dist/commonjs/parser/index.js +356 -337
- package/dist/commonjs/parser/index.js.map +1 -1
- package/dist/commonjs/parser/parser.js +85 -30
- package/dist/commonjs/parser/parser.js.map +1 -1
- package/dist/commonjs/shared/ast.js +302 -0
- package/dist/commonjs/shared/ast.js.map +1 -0
- package/dist/commonjs/shared/parse5.js +1 -15
- package/dist/commonjs/shared/parse5.js.map +1 -1
- package/dist/commonjs/shared/types.js +1 -7
- package/dist/commonjs/shared/types.js.map +1 -1
- package/dist/types/codegen/codegen.d.ts +25 -3
- package/dist/types/codegen/helpers.d.ts +11 -5
- package/dist/types/codegen/index.d.ts +2 -2
- package/dist/types/index.d.ts +1 -2
- package/dist/types/parser/attribute.d.ts +12 -7
- package/dist/types/parser/constants.d.ts +3 -6
- package/dist/types/parser/expression.d.ts +3 -4
- package/dist/types/parser/parser.d.ts +57 -28
- package/dist/types/shared/ast.d.ts +45 -0
- package/dist/types/shared/estree.d.ts +0 -2
- package/dist/types/shared/parse5.d.ts +0 -1
- package/dist/types/shared/types.d.ts +128 -86
- package/package.json +4 -4
- package/dist/commonjs/codegen/scope.js +0 -61
- package/dist/commonjs/codegen/scope.js.map +0 -1
- package/dist/commonjs/shared/ir.js +0 -90
- package/dist/commonjs/shared/ir.js.map +0 -1
- package/dist/types/codegen/scope.d.ts +0 -8
- package/dist/types/shared/ir.d.ts +0 -15
|
@@ -1,36 +1,12 @@
|
|
|
1
|
-
import * as parse5 from 'parse5';
|
|
2
1
|
import { CompilerDiagnostic } from '@lwc/errors';
|
|
3
|
-
export declare type TemplateIdentifier = {
|
|
4
|
-
type: 'Identifier';
|
|
5
|
-
name: string;
|
|
6
|
-
};
|
|
7
|
-
export declare type TemplateExpression = {
|
|
8
|
-
type: 'MemberExpression';
|
|
9
|
-
object: TemplateExpression;
|
|
10
|
-
property: TemplateExpression;
|
|
11
|
-
computed: boolean;
|
|
12
|
-
optional: boolean;
|
|
13
|
-
} | {
|
|
14
|
-
type: 'Literal';
|
|
15
|
-
value: string | number | boolean | null;
|
|
16
|
-
} | TemplateIdentifier;
|
|
17
2
|
export declare type TemplateCompileResult = {
|
|
18
3
|
code: string;
|
|
19
4
|
warnings: CompilerDiagnostic[];
|
|
20
5
|
};
|
|
21
6
|
export declare type TemplateParseResult = {
|
|
22
|
-
root?:
|
|
7
|
+
root?: Root;
|
|
23
8
|
warnings: CompilerDiagnostic[];
|
|
24
9
|
};
|
|
25
|
-
export interface ForEach {
|
|
26
|
-
expression: TemplateExpression;
|
|
27
|
-
item: TemplateIdentifier;
|
|
28
|
-
index?: TemplateIdentifier;
|
|
29
|
-
}
|
|
30
|
-
export interface ForIterator {
|
|
31
|
-
expression: TemplateExpression;
|
|
32
|
-
iterator: TemplateIdentifier;
|
|
33
|
-
}
|
|
34
10
|
export declare enum LWCDirectiveDomMode {
|
|
35
11
|
manual = "manual"
|
|
36
12
|
}
|
|
@@ -38,74 +14,140 @@ export declare enum LWCDirectiveRenderMode {
|
|
|
38
14
|
shadow = "shadow",
|
|
39
15
|
light = "light"
|
|
40
16
|
}
|
|
41
|
-
export interface
|
|
42
|
-
|
|
17
|
+
export interface BaseNode {
|
|
18
|
+
type: string;
|
|
19
|
+
location: SourceLocation;
|
|
43
20
|
}
|
|
44
|
-
export interface
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
21
|
+
export interface SourceLocation {
|
|
22
|
+
startLine: number;
|
|
23
|
+
startColumn: number;
|
|
24
|
+
endLine: number;
|
|
25
|
+
endColumn: number;
|
|
26
|
+
start: number;
|
|
27
|
+
end: number;
|
|
50
28
|
}
|
|
51
|
-
export interface
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
ifModifier?: string;
|
|
74
|
-
forEach?: ForEach;
|
|
75
|
-
forOf?: ForIterator;
|
|
76
|
-
forKey?: TemplateExpression;
|
|
77
|
-
lwc?: LWCDirectives;
|
|
78
|
-
slotName?: string;
|
|
79
|
-
}
|
|
80
|
-
export interface IRText extends IRBaseNode<parse5.TextNode> {
|
|
81
|
-
type: 'text';
|
|
82
|
-
value: string | TemplateExpression;
|
|
83
|
-
}
|
|
84
|
-
export interface IRComment extends IRBaseNode<parse5.CommentNode> {
|
|
85
|
-
type: 'comment';
|
|
86
|
-
value: string;
|
|
29
|
+
export interface ElementSourceLocation extends SourceLocation {
|
|
30
|
+
startTag: SourceLocation;
|
|
31
|
+
endTag?: SourceLocation;
|
|
32
|
+
}
|
|
33
|
+
export interface Literal<Value = string | boolean> {
|
|
34
|
+
type: 'Literal';
|
|
35
|
+
value: Value;
|
|
36
|
+
}
|
|
37
|
+
export interface Identifier extends BaseNode {
|
|
38
|
+
type: 'Identifier';
|
|
39
|
+
name: string;
|
|
40
|
+
}
|
|
41
|
+
export interface MemberExpression extends BaseNode {
|
|
42
|
+
type: 'MemberExpression';
|
|
43
|
+
object: Expression;
|
|
44
|
+
property: Identifier;
|
|
45
|
+
}
|
|
46
|
+
export declare type Expression = Identifier | MemberExpression;
|
|
47
|
+
export interface Attribute extends BaseNode {
|
|
48
|
+
type: 'Attribute';
|
|
49
|
+
name: string;
|
|
50
|
+
value: Literal | Expression;
|
|
87
51
|
}
|
|
88
|
-
export
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
52
|
+
export interface Property extends BaseNode {
|
|
53
|
+
type: 'Property';
|
|
54
|
+
name: string;
|
|
55
|
+
value: Literal | Expression;
|
|
56
|
+
}
|
|
57
|
+
export interface EventListener extends BaseNode {
|
|
58
|
+
type: 'EventListener';
|
|
59
|
+
name: string;
|
|
60
|
+
handler: Expression;
|
|
93
61
|
}
|
|
94
|
-
export interface
|
|
62
|
+
export interface Directive extends BaseNode {
|
|
63
|
+
type: 'Directive';
|
|
95
64
|
name: string;
|
|
96
|
-
|
|
97
|
-
|
|
65
|
+
value: Expression | Literal;
|
|
66
|
+
}
|
|
67
|
+
export interface KeyDirective extends Directive {
|
|
68
|
+
name: 'Key';
|
|
69
|
+
value: Expression;
|
|
70
|
+
}
|
|
71
|
+
export interface DynamicDirective extends Directive {
|
|
72
|
+
name: 'Dynamic';
|
|
73
|
+
value: Expression;
|
|
98
74
|
}
|
|
99
|
-
export interface
|
|
100
|
-
|
|
101
|
-
value:
|
|
75
|
+
export interface DomDirective extends Directive {
|
|
76
|
+
name: 'Dom';
|
|
77
|
+
value: Literal<'manual'>;
|
|
102
78
|
}
|
|
103
|
-
export interface
|
|
104
|
-
|
|
79
|
+
export interface InnerHTMLDirective extends Directive {
|
|
80
|
+
name: `InnerHTML`;
|
|
81
|
+
value: Expression | Literal<string>;
|
|
82
|
+
}
|
|
83
|
+
export interface RenderModeDirective extends Directive {
|
|
84
|
+
name: 'RenderMode';
|
|
85
|
+
value: Literal<LWCDirectiveRenderMode>;
|
|
86
|
+
}
|
|
87
|
+
export interface PreserveCommentsDirective extends Directive {
|
|
88
|
+
name: 'PreserveComments';
|
|
89
|
+
value: Literal<boolean>;
|
|
90
|
+
}
|
|
91
|
+
export declare type ElementDirective = KeyDirective | DynamicDirective | DomDirective | InnerHTMLDirective;
|
|
92
|
+
export declare type RootDirective = RenderModeDirective | PreserveCommentsDirective;
|
|
93
|
+
export interface Text extends BaseNode {
|
|
94
|
+
type: 'Text';
|
|
95
|
+
value: Literal | Expression;
|
|
96
|
+
}
|
|
97
|
+
export interface Comment extends BaseNode {
|
|
98
|
+
type: 'Comment';
|
|
105
99
|
value: string;
|
|
106
100
|
}
|
|
107
|
-
export interface
|
|
108
|
-
|
|
109
|
-
|
|
101
|
+
export interface BaseParentNode extends BaseNode {
|
|
102
|
+
children: ChildNode[];
|
|
103
|
+
}
|
|
104
|
+
export interface AbstractBaseElement extends BaseParentNode {
|
|
105
|
+
name: string;
|
|
106
|
+
location: ElementSourceLocation;
|
|
107
|
+
properties: Property[];
|
|
108
|
+
attributes: Attribute[];
|
|
109
|
+
listeners: EventListener[];
|
|
110
|
+
directives: ElementDirective[];
|
|
111
|
+
namespace?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface Element extends AbstractBaseElement {
|
|
114
|
+
type: 'Element';
|
|
115
|
+
}
|
|
116
|
+
export interface Component extends AbstractBaseElement {
|
|
117
|
+
type: 'Component';
|
|
118
|
+
}
|
|
119
|
+
export interface Slot extends AbstractBaseElement {
|
|
120
|
+
type: 'Slot';
|
|
121
|
+
/** Specifies slot element name. An empty string value maps to the default slot. */
|
|
122
|
+
slotName: string;
|
|
123
|
+
}
|
|
124
|
+
export declare type BaseElement = Element | Component | Slot;
|
|
125
|
+
export interface Root extends BaseParentNode {
|
|
126
|
+
type: 'Root';
|
|
127
|
+
location: ElementSourceLocation;
|
|
128
|
+
directives: RootDirective[];
|
|
129
|
+
}
|
|
130
|
+
interface DirectiveParentNode extends BaseParentNode {
|
|
131
|
+
directiveLocation: SourceLocation;
|
|
132
|
+
}
|
|
133
|
+
export interface If extends DirectiveParentNode {
|
|
134
|
+
type: 'If';
|
|
135
|
+
modifier: string;
|
|
136
|
+
condition: Expression;
|
|
137
|
+
}
|
|
138
|
+
export interface ForEach extends DirectiveParentNode {
|
|
139
|
+
type: 'ForEach';
|
|
140
|
+
expression: Expression;
|
|
141
|
+
item: Identifier;
|
|
142
|
+
index?: Identifier;
|
|
143
|
+
}
|
|
144
|
+
export interface ForOf extends DirectiveParentNode {
|
|
145
|
+
type: 'ForOf';
|
|
146
|
+
expression: Expression;
|
|
147
|
+
iterator: Identifier;
|
|
110
148
|
}
|
|
111
|
-
export declare type
|
|
149
|
+
export declare type ForBlock = ForEach | ForOf;
|
|
150
|
+
export declare type ParentNode = Root | ForBlock | If | BaseElement;
|
|
151
|
+
export declare type ChildNode = ForBlock | If | BaseElement | Comment | Text;
|
|
152
|
+
export declare type Node = Root | ForBlock | If | BaseElement | Comment | Text;
|
|
153
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lwc/template-compiler",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Template compiler package",
|
|
5
5
|
"homepage": "https://lwc.dev/",
|
|
6
6
|
"repository": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"//": "Currently can't upgrade estree-walker to v3.0.0 because it dropped CommonJS support: https://git.io/JXguS",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@lwc/errors": "2.
|
|
29
|
-
"@lwc/shared": "2.
|
|
28
|
+
"@lwc/errors": "2.7.0",
|
|
29
|
+
"@lwc/shared": "2.7.0",
|
|
30
30
|
"acorn": "~8.6.0",
|
|
31
31
|
"astring": "~1.8.1",
|
|
32
32
|
"estree-walker": "~2.0.2",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "656663a9f95f90bd648c6fc2200201afc0156393"
|
|
43
43
|
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.bindExpression = void 0;
|
|
23
|
-
/*
|
|
24
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
25
|
-
* All rights reserved.
|
|
26
|
-
* SPDX-License-Identifier: MIT
|
|
27
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
28
|
-
*/
|
|
29
|
-
const estree_walker_1 = require("estree-walker");
|
|
30
|
-
const t = __importStar(require("../shared/estree"));
|
|
31
|
-
const constants_1 = require("../shared/constants");
|
|
32
|
-
const ir_1 = require("../shared/ir");
|
|
33
|
-
/**
|
|
34
|
-
* Bind the passed expression to the component instance. It applies the following transformation to the expression:
|
|
35
|
-
* - {value} --> {$cmp.value}
|
|
36
|
-
* - {value[index]} --> {$cmp.value[$cmp.index]}
|
|
37
|
-
*/
|
|
38
|
-
function bindExpression(expression, irNode, parentStack) {
|
|
39
|
-
if (t.isIdentifier(expression)) {
|
|
40
|
-
if ((0, ir_1.isComponentProp)(expression, irNode, parentStack)) {
|
|
41
|
-
return t.memberExpression(t.identifier(constants_1.TEMPLATE_PARAMS.INSTANCE), expression);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
return expression;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
(0, estree_walker_1.walk)(expression, {
|
|
48
|
-
leave(node, parent) {
|
|
49
|
-
if (parent !== null &&
|
|
50
|
-
t.isIdentifier(node) &&
|
|
51
|
-
t.isMemberExpression(parent) &&
|
|
52
|
-
parent.object === node &&
|
|
53
|
-
(0, ir_1.isComponentProp)(node, irNode, parentStack)) {
|
|
54
|
-
this.replace(t.memberExpression(t.identifier(constants_1.TEMPLATE_PARAMS.INSTANCE), node));
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
return expression;
|
|
59
|
-
}
|
|
60
|
-
exports.bindExpression = bindExpression;
|
|
61
|
-
//# sourceMappingURL=scope.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../src/codegen/scope.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACH,iDAAqC;AAErC,oDAAsC;AACtC,mDAAsD;AACtD,qCAA+C;AAG/C;;;;GAIG;AACH,SAAgB,cAAc,CAC1B,UAA8B,EAC9B,MAAc,EACd,WAAqB;IAErB,IAAI,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE;QAC5B,IAAI,IAAA,oBAAe,EAAC,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE;YAClD,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC,2BAAe,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC;SACjF;aAAM;YACH,OAAO,UAAU,CAAC;SACrB;KACJ;IAED,IAAA,oBAAI,EAAC,UAAU,EAAE;QACb,KAAK,CAAC,IAAI,EAAE,MAAM;YACd,IACI,MAAM,KAAK,IAAI;gBACf,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC;gBACpB,CAAC,CAAC,kBAAkB,CAAC,MAAM,CAAC;gBAC5B,MAAM,CAAC,MAAM,KAAK,IAAI;gBACtB,IAAA,oBAAe,EAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAC5C;gBACE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC,2BAAe,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;aAClF;QACL,CAAC;KACJ,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACtB,CAAC;AA5BD,wCA4BC"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isComponentProp = exports.isIRBooleanAttribute = exports.isIRStringAttribute = exports.isIRExpressionAttribute = exports.isSlot = exports.isTemplate = exports.isCustomElement = exports.isCommentNode = exports.isTextNode = exports.isElement = exports.createComment = exports.createText = exports.createElement = void 0;
|
|
4
|
-
const types_1 = require("./types");
|
|
5
|
-
function createElement(original, location) {
|
|
6
|
-
return {
|
|
7
|
-
type: 'element',
|
|
8
|
-
tag: original.tagName,
|
|
9
|
-
namespace: original.namespaceURI,
|
|
10
|
-
children: [],
|
|
11
|
-
location,
|
|
12
|
-
__original: original,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
exports.createElement = createElement;
|
|
16
|
-
function createText(value, location) {
|
|
17
|
-
return {
|
|
18
|
-
type: 'text',
|
|
19
|
-
value,
|
|
20
|
-
location,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
exports.createText = createText;
|
|
24
|
-
function createComment(value, location) {
|
|
25
|
-
return {
|
|
26
|
-
type: 'comment',
|
|
27
|
-
value,
|
|
28
|
-
location,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
exports.createComment = createComment;
|
|
32
|
-
function isElement(node) {
|
|
33
|
-
return node.type === 'element';
|
|
34
|
-
}
|
|
35
|
-
exports.isElement = isElement;
|
|
36
|
-
function isTextNode(node) {
|
|
37
|
-
return node.type === 'text';
|
|
38
|
-
}
|
|
39
|
-
exports.isTextNode = isTextNode;
|
|
40
|
-
function isCommentNode(node) {
|
|
41
|
-
return node.type === 'comment';
|
|
42
|
-
}
|
|
43
|
-
exports.isCommentNode = isCommentNode;
|
|
44
|
-
function isCustomElement(node) {
|
|
45
|
-
return isElement(node) && node.component !== undefined;
|
|
46
|
-
}
|
|
47
|
-
exports.isCustomElement = isCustomElement;
|
|
48
|
-
function isTemplate(element) {
|
|
49
|
-
return element.tag === 'template';
|
|
50
|
-
}
|
|
51
|
-
exports.isTemplate = isTemplate;
|
|
52
|
-
function isSlot(element) {
|
|
53
|
-
return element.tag === 'slot';
|
|
54
|
-
}
|
|
55
|
-
exports.isSlot = isSlot;
|
|
56
|
-
function isIRExpressionAttribute(attribute) {
|
|
57
|
-
return attribute.type === types_1.IRAttributeType.Expression;
|
|
58
|
-
}
|
|
59
|
-
exports.isIRExpressionAttribute = isIRExpressionAttribute;
|
|
60
|
-
function isIRStringAttribute(attribute) {
|
|
61
|
-
return attribute.type === types_1.IRAttributeType.String;
|
|
62
|
-
}
|
|
63
|
-
exports.isIRStringAttribute = isIRStringAttribute;
|
|
64
|
-
function isIRBooleanAttribute(attribute) {
|
|
65
|
-
return attribute.type === types_1.IRAttributeType.Boolean;
|
|
66
|
-
}
|
|
67
|
-
exports.isIRBooleanAttribute = isIRBooleanAttribute;
|
|
68
|
-
function isComponentProp(identifier, root, parentStack) {
|
|
69
|
-
var _a;
|
|
70
|
-
const { name } = identifier;
|
|
71
|
-
let current = root;
|
|
72
|
-
// Walking up the AST and checking for each node to find if the identifer name is identical to
|
|
73
|
-
// an iteration variable.
|
|
74
|
-
for (let i = parentStack.length; i >= 0; i--) {
|
|
75
|
-
if (isElement(current)) {
|
|
76
|
-
const { forEach, forOf } = current;
|
|
77
|
-
if ((forEach === null || forEach === void 0 ? void 0 : forEach.item.name) === name ||
|
|
78
|
-
((_a = forEach === null || forEach === void 0 ? void 0 : forEach.index) === null || _a === void 0 ? void 0 : _a.name) === name ||
|
|
79
|
-
(forOf === null || forOf === void 0 ? void 0 : forOf.iterator.name) === name) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
current = parentStack[i - 1];
|
|
84
|
-
}
|
|
85
|
-
// The identifier is bound to a component property if no match is found after reaching to AST
|
|
86
|
-
// root.
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
exports.isComponentProp = isComponentProp;
|
|
90
|
-
//# sourceMappingURL=ir.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ir.js","sourceRoot":"","sources":["../../../src/shared/ir.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as t from '../shared/estree';
|
|
2
|
-
import { IRNode, TemplateExpression } from '../shared/types';
|
|
3
|
-
/**
|
|
4
|
-
* Bind the passed expression to the component instance. It applies the following transformation to the expression:
|
|
5
|
-
* - {value} --> {$cmp.value}
|
|
6
|
-
* - {value[index]} --> {$cmp.value[$cmp.index]}
|
|
7
|
-
*/
|
|
8
|
-
export declare function bindExpression(expression: TemplateExpression, irNode: IRNode, parentStack: IRNode[]): t.Expression;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as parse5 from 'parse5';
|
|
2
|
-
import { TemplateIdentifier, TemplateExpression, IRNode, IRText, IRElement, IRComment, IRAttribute, IRExpressionAttribute, IRStringAttribute, IRBooleanAttribute } from './types';
|
|
3
|
-
export declare function createElement(original: parse5.Element, location: parse5.ElementLocation): IRElement;
|
|
4
|
-
export declare function createText(value: string | TemplateExpression, location: parse5.Location): IRText;
|
|
5
|
-
export declare function createComment(value: string, location: parse5.Location): IRComment;
|
|
6
|
-
export declare function isElement(node: IRNode): node is IRElement;
|
|
7
|
-
export declare function isTextNode(node: IRNode): node is IRText;
|
|
8
|
-
export declare function isCommentNode(node: IRNode): node is IRComment;
|
|
9
|
-
export declare function isCustomElement(node: IRNode): boolean;
|
|
10
|
-
export declare function isTemplate(element: IRElement): boolean;
|
|
11
|
-
export declare function isSlot(element: IRElement): boolean;
|
|
12
|
-
export declare function isIRExpressionAttribute(attribute: IRAttribute): attribute is IRExpressionAttribute;
|
|
13
|
-
export declare function isIRStringAttribute(attribute: IRAttribute): attribute is IRStringAttribute;
|
|
14
|
-
export declare function isIRBooleanAttribute(attribute: IRAttribute): attribute is IRBooleanAttribute;
|
|
15
|
-
export declare function isComponentProp(identifier: TemplateIdentifier, root: IRNode, parentStack: IRNode[]): boolean;
|