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

fix($compile): allow the usage of "$" in isolated scope property alias #15594

Closed
wants to merge 3 commits into from
Closed

fix($compile): allow the usage of "$" in isolated scope property alias #15594

wants to merge 3 commits into from

Conversation

frederikprijck
Copy link
Contributor

@frederikprijck frederikprijck commented Jan 11, 2017

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

Error: [$compile:iscp] Invalid controller bindings definition for directive 'foo'. Definition: {... factory: '<$fooFactory' ...}

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:

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
@frederikprijck frederikprijck changed the title fix($compile): allow the usage of "$" in isolated scope property alias feature($compile): allow the usage of "$" in isolated scope property alias Jan 11, 2017
@frederikprijck frederikprijck changed the title feature($compile): allow the usage of "$" in isolated scope property alias feat($compile): allow the usage of "$" in isolated scope property alias Jan 11, 2017
@frederikprijck frederikprijck changed the title feat($compile): allow the usage of "$" in isolated scope property alias feat($compile): allow the usage of "$" as an optional prefix or suffix in isolated scope property alias 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*$/;
Copy link
Member

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$]*.

Copy link
Contributor Author

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.

@frederikprijck frederikprijck changed the title feat($compile): allow the usage of "$" as an optional prefix or suffix in isolated scope property alias feat($compile): allow the usage of "$" in isolated scope property alias Jan 11, 2017
Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@frederikprijck frederikprijck changed the title feat($compile): allow the usage of "$" in isolated scope property alias fix($compile): allow the usage of "$" in isolated scope property alias Jan 11, 2017
@gkalpak gkalpak closed this in 9c722cf Jan 11, 2017
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
@frederikprijck frederikprijck deleted the fix/$compile branch January 11, 2017 11:37
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.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Component bindings: {} validation is too restrictive (does not allow dollar sign)
4 participants