X Tutup
Skip to content

HtmlLexer: allow "<" in text nodes#5657

Closed
vicb wants to merge 2 commits intoangular:masterfrom
vicb:1206-lexLT
Closed

HtmlLexer: allow "<" in text nodes#5657
vicb wants to merge 2 commits intoangular:masterfrom
vicb:1206-lexLT

Conversation

@vicb
Copy link
Copy Markdown
Contributor

@vicb vicb commented Dec 6, 2015

As reported in #5550, {{ a < b ? c : d }} would throw because the lexer interpret "<" as the start of an element.

While the error is legit according to HTML specs, replacing < with &gt; would be ugly in angular expression.

This use case is probable with Angular and browsers would handle it. This PR makes the lexer more lenient and <... is now interpreted as a text node when it would otherwise start a malformed start tag.

A drawback is that some other error cases could not be reported any more, see the updates in the spec file for more info.

Notes:

  • The second commit fixes a bug that was allowing spaces in between < and the tag name
  • This lenient behavior does not apply for malformed end tag </... because they are less likely to be part of an angular expression and Chrome would transform them to comments nodes.

/cc @yjbanov

@vicb vicb added feature Label used to distinguish feature request from other issues action: review The PR is still awaiting reviews from at least one requested reviewer comp: core/view/compiler labels Dec 6, 2015
@vicb vicb added this to the beta.0 milestone Dec 6, 2015
@tbosch
Copy link
Copy Markdown
Contributor

tbosch commented Dec 7, 2015

I am not in favor of this. The real solution is to integrate the html parser with the expression parser. Then we know when an expression starts and when it ends, and don't get confused whether a < is an element start or actually part of an expression.

@tbosch tbosch added pr_state: LGTM action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Dec 7, 2015
@vicb vicb mentioned this pull request Dec 7, 2015
@vicb
Copy link
Copy Markdown
Contributor Author

vicb commented Dec 8, 2015

agree with @tbosch (created #5679 as a follow up issue)

we have reviewed the PR together

@vicb vicb added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Dec 8, 2015
@vicb vicb mentioned this pull request Dec 8, 2015
@jelbourn jelbourn closed this Dec 8, 2015
@vicb vicb deleted the 1206-lexLT branch June 9, 2017 17:15
@angular-automatic-lock-bot
Copy link
Copy Markdown

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes feature Label used to distinguish feature request from other issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

X Tutup