This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($compile): allow the usage of "$" in isolated scope property alias #15594
Closed
Conversation
This file contains hidden or 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
When using an alias for an isolated scope property using "$" as part of the alias, the $compile throws an exception Error: [$compile:iscp] Invalid controller bindings definition for directive 'foo'. Definition: {... factory: '<$fooFactory' ...} This commit removes the error by changing the regex to allow zero or one "$" character both at the beginning and the end of the alias. Fixes: #15586
gkalpak
suggested changes
Jan 11, 2017
@@ -983,7 +983,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { | |||
var bindingCache = createMap(); | |||
|
|||
function parseIsolateBindings(scope, directiveName, isController) { | |||
var LOCAL_REGEXP = /^\s*([@&<]|=(\*?))(\??)\s*(\w*)\s*$/; | |||
var LOCAL_REGEXP = /^\s*([@&<]|=(\*?))(\??)\s*([$]?\w*[$]?)\s*$/; |
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.
I don't think there is any harm in allowing $
anywhere in the name, so I would change [$]?\w*[$]?
to [\w$]*
.
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.
Gotta admit I was thinking the same. But I prefered to open the PR to fix only as described in the bug.
I'll fix it.
gkalpak
approved these changes
Jan 11, 2017
petebacondarwin
approved these changes
Jan 11, 2017
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.
LGTM
gkalpak
pushed a commit
that referenced
this pull request
Jan 11, 2017
Previously, when using an alias for an isolate scope or `bindings` property (e.g. `alias: '<attrName'` instead of `attrName: '<'`), a `$compile:iscp` error was thrown if the attribute name contained a "$". This commit removes the error by changing the regex to allow "$" characters in the attribute name when using a property alias. Fixes: #15586 Closes #15594
gkalpak
pushed a commit
that referenced
this pull request
Jan 11, 2017
Previously, when using an alias for an isolate scope or `bindings` property (e.g. `alias: '<attrName'` instead of `attrName: '<'`), a `$compile:iscp` error was thrown if the attribute name contained a "$". This commit removes the error by changing the regex to allow "$" characters in the attribute name when using a property alias. Fixes: #15586 Closes #15594
ellimist
pushed a commit
to ellimist/angular.js
that referenced
this pull request
Mar 15, 2017
Previously, when using an alias for an isolate scope or `bindings` property (e.g. `alias: '<attrName'` instead of `attrName: '<'`), a `$compile:iscp` error was thrown if the attribute name contained a "$". This commit removes the error by changing the regex to allow "$" characters in the attribute name when using a property alias. Fixes: angular#15586 Closes angular#15594
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug
What is the current behavior? (You can also link to an open issue here)
When using an alias for an isolated scope property using "$" as part of the alias, the $compile throws an exception
Fixes: #15586
What is the new behavior (if this is a feature change)?
This commit removes the error by changing the regex to allow zero or one "$" character both at the beginning and the end of the alias.
Does this PR introduce a breaking change?
No.
Please check if the PR fulfills these requirements
Other information: