This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix($compile): throw error on invalid directive name
Directive names must start with a lower case letter. Previously the compiler would quietly fail. This change adds an assertion that fails if this is not the case. Closes #11281 Closes #11109
- Loading branch information
1 parent
e57138d
commit 170ff9a
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@ngdoc error | ||
@name $compile:baddir | ||
@fullName Invalid Directive Name | ||
@description | ||
|
||
This error occurs when the name of a directive is not valid. | ||
|
||
Directives must start with a lowercase character. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170ff9a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wesleycho The real name of the function assertValidDirectiveName should be assertFirstLetterLowercase. I'm not trying to troll here :) Just to maybe start some discussion whether the directive names should be validated or not. I've mention that a bit in this issue: #11397
Currently you could name a directive any of those example chars: < > " | (or single space). Would that be valid directive name? assertValidDirectiveName would say yes :) But then how would you use this directive in a html?
170ff9a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jtorbicki - it is funny that you say this because it was indeed called something like that in @wesleycho's original PR: #11281 (diff)
But the point is that we should probably make this method more strict as you suggest rather than rename it.