Skip to content

Commit 2ce8ede

Browse files
committed
feat: enhance angular template parsing to support additional animation attributes - fixes #2
1 parent 1770c1b commit 2ce8ede

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

xmlParser.spec.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,27 +111,39 @@ describe('XmlParser', () => {
111111
});
112112
it('should parse angular template', () => {
113113
const fragment = `<div someDirective #someRef></div>
114-
<app-radio-group [formControl]="control">
115-
<app-radio-button *ngFor="let item of dialogData.items" [value]="item">
114+
<app-radio-group [formControl]="control" [@myAnimation]="state">
115+
<app-radio-button *ngFor="let item of dialogData.items" [value]="item" [@myAnimationWithoutState]>
116116
{{ displayLabel(item) }}
117117
</app-radio-button>
118118
</app-radio-group>
119119
<button type="button" (click)="confirmChoice()" i18n="@@APPLY_BUTTON">OK</button>
120120
`;
121121
const nodes = XmlParser.parseFragment(fragment);
122122

123-
expect(nodes.map(n => n.toString()).join('')).toEqual(fragment);
123+
expect(nodes.map((n) => n.toString()).join('')).toEqual(fragment);
124124
expect(nodes).toEqual([
125-
new XmlElement('div', [new XmlAttribute('someDirective', '', ' ', '', '', '"', false), new XmlAttribute('#someRef', '', ' ', '', '', '"', false)], [], ''),
125+
new XmlElement(
126+
'div',
127+
[
128+
new XmlAttribute('someDirective', '', ' ', '', '', '"', false),
129+
new XmlAttribute('#someRef', '', ' ', '', '', '"', false),
130+
],
131+
[],
132+
'',
133+
),
126134
new XmlText('\n '),
127135
new XmlElement(
128136
'app-radio-group',
129-
[new XmlAttribute('[formControl]', 'control')],
137+
[new XmlAttribute('[formControl]', 'control'), new XmlAttribute('[@myAnimation]', 'state')],
130138
[
131139
new XmlText('\n '),
132140
new XmlElement(
133141
'app-radio-button',
134-
[new XmlAttribute('*ngFor', 'let item of dialogData.items'), new XmlAttribute('[value]', 'item')],
142+
[
143+
new XmlAttribute('*ngFor', 'let item of dialogData.items'),
144+
new XmlAttribute('[value]', 'item'),
145+
new XmlAttribute('[@myAnimationWithoutState]', '', ' ', '', '', '"', false),
146+
],
135147
[new XmlText('\n {{ displayLabel(item) }}\n ')],
136148
'',
137149
false,

xmlParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export class XmlParser {
231231
// Reads a name (letters, digits, underscore, hyphen, colon, period).
232232
readName(): string {
233233
const start = this.pos;
234-
while (this.pos < this.input.length && /[A-Za-z0-9_\-.:\[\]*()#]/.test(this.input[this.pos])) {
234+
while (this.pos < this.input.length && /[A-Za-z0-9_\-.:\[\]*()#@]/.test(this.input[this.pos])) {
235235
this.pos++;
236236
}
237237
return this.input.substring(start, this.pos);

0 commit comments

Comments
 (0)