Skip to content

HTML tokenization does not handle CR correctly #5618

Closed

Description

@wardbell

After upgrading from alpha46 to alpha47, there seems to be some extra spacing added when projecting elements via ng-content or using anything <template> related (ng-if, ng-switch, ng-for).

[copied from Filipe's issue #440 registered in angular.io ]

plunker alpha46: http://plnkr.co/edit/698ShxZ0FhziYHxCu3t3?p=preview
image

plunker alpha47: http://plnkr.co/edit/R8biozWaYxy1VcKJLqiQ?p=preview
image

Activity

  1. vicb commented on Dec 5, 2015

    @vicb
    Contributor

    Probably linked to the content of the text node ("HQ alerts: no alerts, everything normal.")

    On alpha 47 it is (char codes): 13-10-32-32-72-81

    On alpha 46 it is: 10-32-32-72-81-...

    Notice the extra CR on alpha 47.

    Probably related to the new parser. I'll have to investigate more next week.

    /cc @tbosch

  2. vicb commented on Dec 5, 2015

    @vicb
    Contributor

    The clue might be http://www.w3.org/TR/html5/syntax.html#preprocessing-the-input-stream

    "CR" (U+000D) characters and "LF" (U+000A) characters are treated specially. All CR characters must be converted to LF characters, and any LF characters that immediately follow a CR character must be ignored. Thus, newlines in HTML DOMs are represented by LF characters, and there are never any CR characters in the input to the tokenization stage.

    (related: LF has a special handling after textarea, pre & listing).

  3. changed the title [-]template/ng-content adding extra spacing in alpha47[/-] [+]HTML tokenization does not handle CR correctly[/+] on Dec 5, 2015
  4. vicb commented on Dec 5, 2015

    @vicb
    Contributor

    I have updated the title of the issue to better reflect what the bug is (the one described in my previous message).

    It should not be too hard to solve but it's not too easy either (as we want to preserve the source location while parsing the html - ie it is not a simple as a "find & replace").

  5. vicb commented on Dec 5, 2015

    @vicb
    Contributor

    Actually I think we can convert CRLF to CR then CR to LF and preserving source position should not be a problem. I'll try to PR soon.

  6. filipesilva commented on Dec 5, 2015

    @filipesilva
    Contributor

    @vicb I've created bundles from your branch and replaces the ones in my code. It seems to fix the issue. Thanks!

    The ng-content text node ("HQ alerts: no alerts, everything normal.") is aligned with the header above, and the space between template instances is also gone.

    image

  7. vicb commented on Dec 7, 2015

    @vicb
    Contributor

    Great, thank you so much for having tested !

  8. filipesilva commented on Dec 7, 2015

    @filipesilva
    Contributor

    Thank you for fixing it :p

  9. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  10. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions