Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

directive name should be trimmed #11397

Closed
jtorbicki opened this Issue Mar 22, 2015 · 3 comments

Comments

Projects
None yet
4 participants
@jtorbicki
Copy link
Contributor

commented Mar 22, 2015

Directive name should probably be either trimmed or angular should throw an exception, so a typo is easier to spot. Leading or following space is clearly an error.

In the following example the name is 'directiveName ' instead of 'directiveName':

https://jsfiddle.net/c2ztgdjr/

Maybe same rule should be applied to controllers, factories etc, although it's still possible to inject those with an extra space.

jtorbicki referenced this issue Mar 24, 2015

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
@pkozlowski-opensource

This comment has been minimized.

Copy link
Member

commented Apr 28, 2015

I would say we should throw. This would be an easy fix in the compiler, see

function assertValidDirectiveName(name) {

Anyone fancy sending a PR with an associated test?

@pkozlowski-opensource pkozlowski-opensource added this to the Backlog milestone Apr 28, 2015

lugovsky added a commit to akveoDev/angular.js that referenced this issue Apr 30, 2015

fix($compile): validate directive name for whitespaces
Throw an exception if directive name contains leading or trailing whitespaces

Closes angular#11397
@lugovsky

This comment has been minimized.

Copy link
Contributor

commented Apr 30, 2015

@pkozlowski-opensource Hey! Please check the PR for this issue. Thanks!

lugovsky added a commit to akveoDev/angular.js that referenced this issue Apr 30, 2015

fix($compile): change directive name validation error entry
As angular team suggested, it's better use 'baddir' error entry for whitespace validation.

Closes angular#11397

lugovsky added a commit to akveoDev/angular.js that referenced this issue Apr 30, 2015

docs($compile): change documentation for baddir error entry
Add additional condition, when baddir error could happen.

Closes angular#11397

lugovsky added a commit to akveoDev/angular.js that referenced this issue Apr 30, 2015

fix($compile): validate directive name for whitespaces
Throw an exception if directive name contains leading or trailing whitespaces

Closes angular#11397

netman92 added a commit to netman92/angular.js that referenced this issue Aug 8, 2015

@chris-trotter

This comment has been minimized.

Copy link

commented Mar 15, 2017

Be careful not to have an upper case character at the beginning of your component name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.