Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Template-level @preserveWhitespace "annotation" #1295

Closed
matanlurey opened this issue May 2, 2018 · 2 comments
Closed

Template-level @preserveWhitespace "annotation" #1295

matanlurey opened this issue May 2, 2018 · 2 comments

Comments

@matanlurey
Copy link
Contributor

For example:

<div>
  Collapse whitespace
  <div @preserveWhitespace>Preserve  All  Whitespace</div>
</div>
@matanlurey
Copy link
Contributor Author

matanlurey commented Jul 7, 2018

Spent ~15 minutes on this, mostly gathering requirements:

  • Would be nice to do Refactor out a HasChildrenAst #1460 first
  • EmbeddedTemplateAst needs support for .annotations
  • MinimizeWhitespaceVisitor uses RecursiveAstVisitor, so you need to bail out (no super.)

Some example test cases:

test('should skip nodes annotated with @preserveWhitespace', () {
  expect(
    _parseAndMinifiy(
      r'<div @preserveWhitespace>   <span>  </span></div>',
    ),
    '<div @preserveWhitespace>   <span>  </span></div>',
  );
  expect(
    _parseAndMinifiy(
      r'<ng-container @preserveWhitespace>   </ng-container>',
    ),
    '<ng-container @preserveWhitespace>   </ng-container>',
  );
  expect(
    _parseAndMinifiy(
      r'<template @preserveWhitespace><div>  </div></template>',
    ),
    '<template @preserveWhitespace><div>  </div></template>',
  );
});

@matanlurey
Copy link
Contributor Author

Fixed in #1464.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant