-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat($parse): toggle evaluation of private fields via $parseProvider.allowPrivateFields() #4849
Conversation
…allowPrivateFields() Disallowing evaluation of private fields in Angular expressions should be toggleable through a `config()` block. Usage is shown in ngdoc comments.
I'd definetly vote for that , though OFF by default would make more sense, let me write javascript with MY dev team conventions. |
How about making the check itself customizable? Rather than a boolean flag for allow/disallow, it could accept a function that checks if a name is accessible or not and returns a boolean. |
It defaults to @eknkc May be a good idea but the motivation here was simply to toggle the existing functionality, not provide anything new. |
@boneskull sage :) @eknkc Passing |
This is simple, to the point, and follows the existing $parseProvider conventions. 👍 |
I agree that that this is a good solution, but also believe the default should be Causing a wide reaching breaking change like this should only be done where absolutely necessary, I don't believe the proposed problem the breaking change solves warrant's the pain it will cause. Currently any teams using a MongoDB or CouchDB backed application will get a very rude introduction to 1.2.0. |
I think it should be
|
+1 @cburgdorf - this is the ideal solution |
IMO it should be a combination of the OP and @cburgdorf. It feels a bit magic to disable private fields because the prefix is an empty string. It feels like a not-so-obvious side effect. But on the other hand it's a nice feature to be able to change the prefix.
Notice I changed |
👍 If this is made customizable without ability to just switch it off, then people will just set random strings as prefixes and it will just slow their applications down. |
I think the api should be something like: $parseProvider.restrictFieldsMatching(/^_/);
|
With null meaning "switch it off"
|
Guys, take a look into #4859 and tell me what you think... It implements Pete's proposal. |
+1 for this |
Thats what we need. |
👍 |
1 similar comment
+1 |
Hiding `_*` properties was a feature primarily for developers using Closure compiler and Google JS style. We didn't realize how many people will be affected by this change. We might introduce this feature in the future, probably under a config option, but it needs more research and so I'm reverting the change for now. This reverts commit 3d6a89e. Closes angular#4926 Closes angular#4842 Closes angular#4865 Closes angular#4859 Closes angular#4849 Conflicts: src/ng/parse.js
Hiding `_*` properties was a feature primarily for developers using Closure compiler and Google JS style. We didn't realize how many people will be affected by this change. We might introduce this feature in the future, probably under a config option, but it needs more research and so I'm reverting the change for now. This reverts commit 3d6a89e. Closes angular#4926 Closes angular#4842 Closes angular#4865 Closes angular#4859 Closes angular#4849 Conflicts: src/ng/parse.js
Disallowing evaluation of private fields in Angular expressions should be toggleable through a
config()
block. Usage is shown in ngdoc comments.It's worth noting that this behavior defaults to FALSE.
That is to say, if you want pre-Angular-1.2 behavior, you must do:
Please let me know if the unit tests are insufficient; they do not consider multiple "formats" of private variables as the tests do in 3d6a89e, but the main intent here was to show that the toggle works.