-
Notifications
You must be signed in to change notification settings - Fork 27.4k
refactor(ngResource): Use core encode methods in ngResource #14309
refactor(ngResource): Use core encode methods in ngResource #14309
Conversation
Looks like a single saucelabs job timed out :P |
@@ -152,7 +152,9 @@ function publishExternalAPI(angular) { | |||
'getTestability': getTestability, | |||
'$$minErr': minErr, | |||
'$$csp': csp, | |||
'reloadWithDebugInfo': reloadWithDebugInfo | |||
'reloadWithDebugInfo': reloadWithDebugInfo, |
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.
This is not a just a refactoring, this exposes these two functions on the angular global, which is something we don't do lightly
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.
You're correct. This is my first patch contributed, so I wasn't sure if this was a big deal or not. Although I do see various utility methods exposed publicly. The nature of the encoding methods makes me feel that they could be useful as public methods.
Interested to hear your thoughts, or general conditions on public methods on the core module. Thanks for the feedback :)
As mentioned by @Narretz, we try to avoid exposing internal helpers/utility functions as public. To expose or not to expose ? 😕 BTW, if we decided to expose them, I would suggest |
Yeah, it was bugging me too. Mainly because I want to propose some changes around some of the encodings, and it seemed wrong to make the identical methods diverge further. @gkalpak Can you point me to an example in the repo of the Thanks! |
Also wondering why this saucelabs test keeps timing out on me :-/ |
I have restarted the build 4 times and the tests keep failing (on Safaris). I wonder if it's a real issue (something to do with the difference introduced in 3625803). WRT |
Usually when I see saucelabs errors like this, it's a fluke. Odd that it's consistent. Can I run those selenium tests locally? I'll update the PR with those pseudo private prefixes too. |
It's the unit tests that fail on Travis. Other tests pass. |
Looks like master is actually failing. |
Core package and ngResource both defined methods for encodeUriQuery and encodeUriSegment. ngResource's methods are out of date. Use core encode methods in ngResource
0cecde8
to
9a58635
Compare
Pseudo private methods are now using |
And now we're passing :) |
@gkalpak Any new thoughts on this? Appreciate the input, thanks! |
I do not like the idea of exposing these function... why not just move these functions to a different file and include this file when building angular core and I know that sharing files between modules is something we currently not do, I just do not like the idea of exposing more helper functions. |
We do it with the loader IIRC, but yeah, we are not doing it with a bunch of other stuff.
I'm not thrilled about it either, but nor do I like the current situation that we duplicate code. Just to be clear, these helper functions, won't be public. They won't be documented and will be So, considering the options:
I don't feel too strongly about either, but slightly favor the first two over the 3rd one. In fact, if we decide to go with the 2nd option (private helpers), we could introduce Another approach would be making those injectable (again behind a |
My thoughts are the same as above ^ Seems like adding build complexity is overkill because these are pseudo private methods. |
Ok, lets go with the current approach. We can always change it later :) |
Awesome :) Excited to get some more patches in related to this issue. |
@lgalfaso, with "current approach" did you mean the one currently in effect or the one proposed in the PR ? (I assume the former, right ?) |
/ping @lgalfaso |
Hello everyone. Hoping for a decision on this, as I have some more patches planned around the encode methods. Thanks :) |
@gkalpak by current approach I meant the one in the PR |
I was about to merge this, when I realized that this is a potential (minor) breaking change. BC or fix? |
If there is a possibility of a BC then let's just put this in 1.6 and document the BC. |
I thought of this as a fix. This is an example of why the duplicate methods were an issue. A PR was merged with a patch for replacing semicolons in the My (this) patch keeps the correct core version of the |
@nicholasserra, the problem is that since |
Understood. 1.6 sounds good. |
I tweaked it a bit, added a test and landed. |
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Refactor
What is the current behavior? (You can also link to an open issue here)
Core package and ngResource both define methods for encodeUriQuery and encodeUriSegment.
ngResource's methods are out of date, as changes were made to core encodeUriQuery over a year ago.
What is the new behavior (if this is a feature change)?
Refactor the usage of these methods in ngResource by removing the duplicate methods, and using the core methods instead.
Does this PR introduce a breaking change?
No
Please check if the PR fulfills these requirements