
committed by
Misko Hevery

parent
a4934a74b6
commit
92e80af875
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
import {AstPath} from '../ast_path';
|
||||
import {AST as I18nAST} from '../i18n/i18n_ast';
|
||||
import {ParseSourceSpan} from '../parse_util';
|
||||
|
||||
export interface Node {
|
||||
@ -15,14 +16,15 @@ export interface Node {
|
||||
}
|
||||
|
||||
export class Text implements Node {
|
||||
constructor(public value: string, public sourceSpan: ParseSourceSpan) {}
|
||||
constructor(public value: string, public sourceSpan: ParseSourceSpan, public i18n?: I18nAST) {}
|
||||
visit(visitor: Visitor, context: any): any { return visitor.visitText(this, context); }
|
||||
}
|
||||
|
||||
export class Expansion implements Node {
|
||||
constructor(
|
||||
public switchValue: string, public type: string, public cases: ExpansionCase[],
|
||||
public sourceSpan: ParseSourceSpan, public switchValueSourceSpan: ParseSourceSpan) {}
|
||||
public sourceSpan: ParseSourceSpan, public switchValueSourceSpan: ParseSourceSpan,
|
||||
public i18n?: I18nAST) {}
|
||||
visit(visitor: Visitor, context: any): any { return visitor.visitExpansion(this, context); }
|
||||
}
|
||||
|
||||
@ -37,7 +39,7 @@ export class ExpansionCase implements Node {
|
||||
export class Attribute implements Node {
|
||||
constructor(
|
||||
public name: string, public value: string, public sourceSpan: ParseSourceSpan,
|
||||
public valueSpan?: ParseSourceSpan) {}
|
||||
public valueSpan?: ParseSourceSpan, public i18n?: I18nAST) {}
|
||||
visit(visitor: Visitor, context: any): any { return visitor.visitAttribute(this, context); }
|
||||
}
|
||||
|
||||
@ -45,7 +47,7 @@ export class Element implements Node {
|
||||
constructor(
|
||||
public name: string, public attrs: Attribute[], public children: Node[],
|
||||
public sourceSpan: ParseSourceSpan, public startSourceSpan: ParseSourceSpan|null = null,
|
||||
public endSourceSpan: ParseSourceSpan|null = null) {}
|
||||
public endSourceSpan: ParseSourceSpan|null = null, public i18n?: I18nAST) {}
|
||||
visit(visitor: Visitor, context: any): any { return visitor.visitElement(this, context); }
|
||||
}
|
||||
|
||||
|
@ -56,12 +56,12 @@ export class WhitespaceVisitor implements html.Visitor {
|
||||
// but still visit all attributes to eliminate one used as a market to preserve WS
|
||||
return new html.Element(
|
||||
element.name, html.visitAll(this, element.attrs), element.children, element.sourceSpan,
|
||||
element.startSourceSpan, element.endSourceSpan);
|
||||
element.startSourceSpan, element.endSourceSpan, element.i18n);
|
||||
}
|
||||
|
||||
return new html.Element(
|
||||
element.name, element.attrs, html.visitAll(this, element.children), element.sourceSpan,
|
||||
element.startSourceSpan, element.endSourceSpan);
|
||||
element.startSourceSpan, element.endSourceSpan, element.i18n);
|
||||
}
|
||||
|
||||
visitAttribute(attribute: html.Attribute, context: any): any {
|
||||
@ -73,7 +73,7 @@ export class WhitespaceVisitor implements html.Visitor {
|
||||
|
||||
if (isNotBlank) {
|
||||
return new html.Text(
|
||||
replaceNgsp(text.value).replace(WS_REPLACE_REGEXP, ' '), text.sourceSpan);
|
||||
replaceNgsp(text.value).replace(WS_REPLACE_REGEXP, ' '), text.sourceSpan, text.i18n);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user