From e03559867b2ccbc58b4ae0660f6cd84896ee199f Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Mon, 28 Aug 2017 15:34:21 +0200 Subject: [PATCH] docs(core): document the preserveWhitespaces option (#18901) Closes #18688 PR Close #18901 --- packages/core/src/metadata/directives.ts | 60 +++++++++++++++++++++--- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/packages/core/src/metadata/directives.ts b/packages/core/src/metadata/directives.ts index a8847605ae..53a17ced0d 100644 --- a/packages/core/src/metadata/directives.ts +++ b/packages/core/src/metadata/directives.ts @@ -678,12 +678,60 @@ export interface Component extends Directive { entryComponents?: Array|any[]>; /** - * If preserveWhitespaces is set to `false` potentially superfluous blank characters (space, tab, - * new line) will be removed from compiled templates. This can greatly reduce generated code size - * as well as speed up components' creation. The whitespace removal algorithm will drop all - * the blank text nodes and collapse series of whitespaces to just one space. - * Those transformations can potentially influence layout of the generated markup so - * the `preserveWhitespaces` should be used with care. + * If {@link Component#preserveWhitespaces `Component.preserveWhitespaces`} is set to `false` + * potentially superfluous whitespace characters (ones matching the `\s` character class in + * JavaScript regular expressions) will be removed from a compiled template. This can greatly + * reduce AOT-generated code size as well as speed up view creation. + * + * Current implementation works according to the following rules: + * - all whitespaces at the beginning and the end of a template are removed (trimmed); + * - text nodes consisting of whitespaces only are removed (ex.: + * ` ` will be converted to + * `` (no whitespaces between buttons); + * - series of whitespaces in text nodes are replaced with one space (ex.: + * `\n some text\n` will be converted to ` some text `); + * - text nodes are left as-is inside HTML tags where whitespaces are significant (ex. `
`,
+   *   `