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

fix($resource): append extra params even if Object.prototype has properties with the same name #14867

Closed
wants to merge 2 commits into from

Conversation

gkalpak
Copy link
Member

@gkalpak gkalpak commented Jul 4, 2016

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix

What is the current behavior? (You can also link to an open issue here)
If Object.prototype has a property named xyz, then an extra xyz param passed to a $resource action call, does not get passed to $http (in config.params).
See #14866.

What is the new behavior (if this is a feature change)?
If Object.prototype has a property named xyz, then an extra xyz param passed to a $resource action call, does get passed to $http (in config.params).

Does this PR introduce a breaking change?
Possibly. If someone relied on using a params object with own, enumerable properties that have the same names with properties on Object.prototype and not have these properties passed to $http (and included in the URL as query params), then this would break them. Highly unlikely though.

Please check if the PR fulfills these requirements

Other information:
Fixes #14866

@Narretz
Copy link
Contributor

Narretz commented Jul 4, 2016

I think we usually did createMap() (which does Object.create(null)) in these cases. Could we apply this here too?

- Use `Object.create(null)` to avoid `hasOwnProperty()` check.
@gkalpak
Copy link
Member Author

gkalpak commented Jul 5, 2016

I think we usually did createMap() (which does Object.create(null)) in these cases

That was my initial intention, but then somehow I forgot 😕
Fixed!

@lgalfaso
Copy link
Contributor

lgalfaso commented Jul 5, 2016

I would change the commit log to Add as params all owned properties and think it is best to squash this into a single commit. Otherwise LGTM

@gkalpak
Copy link
Member Author

gkalpak commented Jul 5, 2016

Should we just merge it in 1.6.x only and mark it as a BC. (I don't expect this to actually break any apps or tests, but it wouldn't be the first time something breaks unexpectedly 😃)

@Narretz
Copy link
Contributor

Narretz commented Jul 5, 2016

Yes, let's merge just in 1.6 with a BC notice. It should be pretty easy to work around this in an affected app (not to mention that this happens rarely)

@gkalpak gkalpak closed this in acb545e Jul 6, 2016
@gkalpak gkalpak deleted the fix-resource-include-params branch July 6, 2016 10:10
@gkalpak
Copy link
Member Author

gkalpak commented Jul 6, 2016

Landed on 1.6.x. Thx for the reviews 😄

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.

$resource v1.5.6 on Firefox-only: does not pass "watch" query string parameter for GET URLs
4 participants