Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

directive name should be trimmed #11397

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

directive name should be trimmed #11397

jtorbicki opened this issue Mar 22, 2015 · 3 comments

Comments

@jtorbicki
Copy link
Contributor

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
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
Copy link
Member

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
Throw an exception if directive name contains leading or trailing whitespaces

Closes angular#11397
@lugovsky
Copy link
Contributor

@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
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
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
Throw an exception if directive name contains leading or trailing whitespaces

Closes angular#11397
netman92 pushed a commit to netman92/angular.js that referenced this issue Aug 8, 2015
@chris-trotter
Copy link

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

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

Successfully merging a pull request may close this issue.

4 participants