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

fix($compile): validate directive name for whitespaces #11772

Closed
wants to merge 1 commit into from

Conversation

lugovsky
Copy link
Contributor

Throw an exception if directive name contains leading or trailing whitespaces

Closes #11397

@gkalpak
Copy link
Member

gkalpak commented Apr 30, 2015

I think you would also need a new baddirwspc.ngdoc file under docs/content/error/$compile/.
E.g. take a look at docs/content/error/$compile/baddir.ngdoc.

@pkozlowski-opensource
Copy link
Member

LGTM, provided that an existing error page is used and its content is updated accordingly

@lugovsky
Copy link
Contributor Author

@pkozlowski-opensource Is the updated error page good enough for you, or probably you would like to structure conditions in a list?

@pkozlowski-opensource
Copy link
Member

Should be fine as a starting point. Could you please squash all the 3 commits into one so it is easier to merge?

Throw an exception if directive name contains leading or trailing whitespaces

Closes angular#11397
@lugovsky
Copy link
Contributor Author

@pkozlowski-opensource Done

@lugovsky
Copy link
Contributor Author

@pkozlowski-opensource Sorry for interrupting you again. I can't understand why CI build failed. Don't see any errors related to my changes. Could you advice on that? :)

@gkalpak
Copy link
Member

gkalpak commented Apr 30, 2015

All is well now :)

@petebacondarwin
Copy link
Member

@pkozlowski-opensource and @gkalpak can you assign this to a milestone and/or deal with it?
Thanks

@gkalpak
Copy link
Member

gkalpak commented May 2, 2015

It LGTM as is, but if we wanted to go the extra mile, we could verify there is no whitespace in the name whatsoever.

@petebacondarwin
Copy link
Member

Is this a breaking change or did the compiler just fail to match directives with leading/trailing whitespace before?

Should we just be more compliant and simply trim directive names?

@gkalpak
Copy link
Member

gkalpak commented May 2, 2015

Previously, the compiler just failed to match the directives, so this is not a breaking change.
I am not sure what is the best approach: throwing an error or trimming names (I'd be happy with either).

If we decide to also check for internal whitespace, then I guess throwing makes more sense.

@pkozlowski-opensource
Copy link
Member

If we decide to also check for internal whitespace, then I guess throwing makes more sense

Personally I would only add additional checks if users keep complaining about common mistakes. Each check cost us frw size and CPU cycles, so checks should be used with moderation, IMO.

@pkozlowski-opensource
Copy link
Member

Ah, and I'm for throwing - I really don't like systems that try to work-around common mistakes, Fail fast is the way to go IMO.

@petebacondarwin
Copy link
Member

OK, let's merge this then.

netman92 pushed a commit to netman92/angular.js that referenced this pull request Aug 8, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

directive name should be trimmed
5 participants