source: trip-planner-front/node_modules/@angular/compiler/esm2015/src/ml_parser/html_whitespaces.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 16.7 KB
Line 
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 */
8import * as html from './ast';
9import { NGSP_UNICODE } from './entities';
10import { ParseTreeResult } from './parser';
11export const PRESERVE_WS_ATTR_NAME = 'ngPreserveWhitespaces';
12const SKIP_WS_TRIM_TAGS = new Set(['pre', 'template', 'textarea', 'script', 'style']);
13// Equivalent to \s with \u00a0 (non-breaking space) excluded.
14// Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
15const WS_CHARS = ' \f\n\r\t\v\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff';
16const NO_WS_REGEXP = new RegExp(`[^${WS_CHARS}]`);
17const WS_REPLACE_REGEXP = new RegExp(`[${WS_CHARS}]{2,}`, 'g');
18function hasPreserveWhitespacesAttr(attrs) {
19 return attrs.some((attr) => attr.name === PRESERVE_WS_ATTR_NAME);
20}
21/**
22 * Angular Dart introduced &ngsp; as a placeholder for non-removable space, see:
23 * https://github.com/dart-lang/angular/blob/0bb611387d29d65b5af7f9d2515ab571fd3fbee4/_tests/test/compiler/preserve_whitespace_test.dart#L25-L32
24 * In Angular Dart &ngsp; is converted to the 0xE500 PUA (Private Use Areas) unicode character
25 * and later on replaced by a space. We are re-implementing the same idea here.
26 */
27export function replaceNgsp(value) {
28 // lexer is replacing the &ngsp; pseudo-entity with NGSP_UNICODE
29 return value.replace(new RegExp(NGSP_UNICODE, 'g'), ' ');
30}
31/**
32 * This visitor can walk HTML parse tree and remove / trim text nodes using the following rules:
33 * - consider spaces, tabs and new lines as whitespace characters;
34 * - drop text nodes consisting of whitespace characters only;
35 * - for all other text nodes replace consecutive whitespace characters with one space;
36 * - convert &ngsp; pseudo-entity to a single space;
37 *
38 * Removal and trimming of whitespaces have positive performance impact (less code to generate
39 * while compiling templates, faster view creation). At the same time it can be "destructive"
40 * in some cases (whitespaces can influence layout). Because of the potential of breaking layout
41 * this visitor is not activated by default in Angular 5 and people need to explicitly opt-in for
42 * whitespace removal. The default option for whitespace removal will be revisited in Angular 6
43 * and might be changed to "on" by default.
44 */
45export class WhitespaceVisitor {
46 visitElement(element, context) {
47 if (SKIP_WS_TRIM_TAGS.has(element.name) || hasPreserveWhitespacesAttr(element.attrs)) {
48 // don't descent into elements where we need to preserve whitespaces
49 // but still visit all attributes to eliminate one used as a market to preserve WS
50 return new html.Element(element.name, html.visitAll(this, element.attrs), element.children, element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
51 }
52 return new html.Element(element.name, element.attrs, visitAllWithSiblings(this, element.children), element.sourceSpan, element.startSourceSpan, element.endSourceSpan, element.i18n);
53 }
54 visitAttribute(attribute, context) {
55 return attribute.name !== PRESERVE_WS_ATTR_NAME ? attribute : null;
56 }
57 visitText(text, context) {
58 const isNotBlank = text.value.match(NO_WS_REGEXP);
59 const hasExpansionSibling = context &&
60 (context.prev instanceof html.Expansion || context.next instanceof html.Expansion);
61 if (isNotBlank || hasExpansionSibling) {
62 // Process the whitespace in the tokens of this Text node
63 const tokens = text.tokens.map(token => token.type === 5 /* TEXT */ ? createWhitespaceProcessedTextToken(token) : token);
64 // Process the whitespace of the value of this Text node
65 const value = processWhitespace(text.value);
66 return new html.Text(value, text.sourceSpan, tokens, text.i18n);
67 }
68 return null;
69 }
70 visitComment(comment, context) {
71 return comment;
72 }
73 visitExpansion(expansion, context) {
74 return expansion;
75 }
76 visitExpansionCase(expansionCase, context) {
77 return expansionCase;
78 }
79}
80function createWhitespaceProcessedTextToken({ type, parts, sourceSpan }) {
81 return { type, parts: [processWhitespace(parts[0])], sourceSpan };
82}
83function processWhitespace(text) {
84 return replaceNgsp(text).replace(WS_REPLACE_REGEXP, ' ');
85}
86export function removeWhitespaces(htmlAstWithErrors) {
87 return new ParseTreeResult(html.visitAll(new WhitespaceVisitor(), htmlAstWithErrors.rootNodes), htmlAstWithErrors.errors);
88}
89function visitAllWithSiblings(visitor, nodes) {
90 const result = [];
91 nodes.forEach((ast, i) => {
92 const context = { prev: nodes[i - 1], next: nodes[i + 1] };
93 const astResult = ast.visit(visitor, context);
94 if (astResult) {
95 result.push(astResult);
96 }
97 });
98 return result;
99}
100//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHRtbF93aGl0ZXNwYWNlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9tbF9wYXJzZXIvaHRtbF93aGl0ZXNwYWNlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEtBQUssSUFBSSxNQUFNLE9BQU8sQ0FBQztBQUM5QixPQUFPLEVBQUMsWUFBWSxFQUFDLE1BQU0sWUFBWSxDQUFDO0FBQ3hDLE9BQU8sRUFBQyxlQUFlLEVBQUMsTUFBTSxVQUFVLENBQUM7QUFHekMsTUFBTSxDQUFDLE1BQU0scUJBQXFCLEdBQUcsdUJBQXVCLENBQUM7QUFFN0QsTUFBTSxpQkFBaUIsR0FBRyxJQUFJLEdBQUcsQ0FBQyxDQUFDLEtBQUssRUFBRSxVQUFVLEVBQUUsVUFBVSxFQUFFLFFBQVEsRUFBRSxPQUFPLENBQUMsQ0FBQyxDQUFDO0FBRXRGLDhEQUE4RDtBQUM5RCxtR0FBbUc7QUFDbkcsTUFBTSxRQUFRLEdBQUcsMEVBQTBFLENBQUM7QUFDNUYsTUFBTSxZQUFZLEdBQUcsSUFBSSxNQUFNLENBQUMsS0FBSyxRQUFRLEdBQUcsQ0FBQyxDQUFDO0FBQ2xELE1BQU0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