[6a3a178] | 1 | /**
|
---|
| 2 | * @license
|
---|
| 3 | * Copyright Google LLC All Rights Reserved.
|
---|
| 4 | *
|
---|
| 5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 6 | * found in the LICENSE file at https://angular.io/license
|
---|
| 7 | */
|
---|
| 8 | import * as html from './ast';
|
---|
| 9 | import { ParseTreeResult } from './parser';
|
---|
| 10 | export declare const PRESERVE_WS_ATTR_NAME = "ngPreserveWhitespaces";
|
---|
| 11 | /**
|
---|
| 12 | * Angular Dart introduced &ngsp; as a placeholder for non-removable space, see:
|
---|
| 13 | * https://github.com/dart-lang/angular/blob/0bb611387d29d65b5af7f9d2515ab571fd3fbee4/_tests/test/compiler/preserve_whitespace_test.dart#L25-L32
|
---|
| 14 | * In Angular Dart &ngsp; is converted to the 0xE500 PUA (Private Use Areas) unicode character
|
---|
| 15 | * and later on replaced by a space. We are re-implementing the same idea here.
|
---|
| 16 | */
|
---|
| 17 | export declare function replaceNgsp(value: string): string;
|
---|
| 18 | /**
|
---|
| 19 | * This visitor can walk HTML parse tree and remove / trim text nodes using the following rules:
|
---|
| 20 | * - consider spaces, tabs and new lines as whitespace characters;
|
---|
| 21 | * - drop text nodes consisting of whitespace characters only;
|
---|
| 22 | * - for all other text nodes replace consecutive whitespace characters with one space;
|
---|
| 23 | * - convert &ngsp; pseudo-entity to a single space;
|
---|
| 24 | *
|
---|
| 25 | * Removal and trimming of whitespaces have positive performance impact (less code to generate
|
---|
| 26 | * while compiling templates, faster view creation). At the same time it can be "destructive"
|
---|
| 27 | * in some cases (whitespaces can influence layout). Because of the potential of breaking layout
|
---|
| 28 | * this visitor is not activated by default in Angular 5 and people need to explicitly opt-in for
|
---|
| 29 | * whitespace removal. The default option for whitespace removal will be revisited in Angular 6
|
---|
| 30 | * and might be changed to "on" by default.
|
---|
| 31 | */
|
---|
| 32 | export declare class WhitespaceVisitor implements html.Visitor {
|
---|
| 33 | visitElement(element: html.Element, context: any): any;
|
---|
| 34 | visitAttribute(attribute: html.Attribute, context: any): any;
|
---|
| 35 | visitText(text: html.Text, context: SiblingVisitorContext | null): any;
|
---|
| 36 | visitComment(comment: html.Comment, context: any): any;
|
---|
| 37 | visitExpansion(expansion: html.Expansion, context: any): any;
|
---|
| 38 | visitExpansionCase(expansionCase: html.ExpansionCase, context: any): any;
|
---|
| 39 | }
|
---|
| 40 | export declare function removeWhitespaces(htmlAstWithErrors: ParseTreeResult): ParseTreeResult;
|
---|
| 41 | interface SiblingVisitorContext {
|
---|
| 42 | prev: html.Node | undefined;
|
---|
| 43 | next: html.Node | undefined;
|
---|
| 44 | }
|
---|
| 45 | export {};
|
---|