-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Firefox-only - Angular runs into problem with a query parameter named 'watch' #8068
Comments
thanks for the report, I'm happy to look into this |
Thanks. It could just be something weird about our app. I've been searching for some kind of working example online to test it with but haven't found one. |
well, I can't reproduce it with a minimal example, I think we need some more details here. Could you try and put together a minimal reproduction on http://plnkr.co ? |
Yeah I will do that when I can get some time. Unfortunately we're under a crazy deadline at the moment. We are on angular 1.2.12 if that makes any difference. |
The simple reproduction isn't broken with 1.2.12 anymore, so I think there's something else going on. But if you can reproduce it I'm happy to look |
You did try it in Firefox right? |
I did --- FF29 and FF33 (Nightly) |
Well I found a good example. It's happening on your website (in Firefox): https://docs.angularjs.org/api/ng/service/$location?watch=test If I use some name other than 'watch' it's fine: https://docs.angularjs.org/api/ng/service/$location?watch2=test |
Okay, that is something I can work with =) |
Okay, so what's happening here is we think that we already have key 'watch' in the object, because FF has So what we end up doing is saying I'll try and put together a fix, it shouldn't be too bad. |
Thanks a ton for the quick replies Caitlin! If you can give me or help me create some kind of monkey-patch that will work with 1.2.12 that would be awesome as well. We still have to support IE 8 for at least a little while longer - so we haven't been able to upgrade to the latest angular yet. |
It's not really monkey-patchable because it's a private API, but I THINK you should be able to just replace And, for IE8, you'd also need to make sure that you can actually use Since this is a bug, once I flesh this out a bit more, we can push it to the 1.2 branch anyways. |
Previously, properties (typically functions) in the prototype chain (Object.prototype) would shadow query parameters, and cause them to be serialized incorrectly. This CL guards against this by using hasOwnProperty() to ensure that only own properties are a concern. Fixes angular#8068
Previously, properties (typically functions) in the prototype chain (Object.prototype) would shadow query parameters, and cause them to be serialized incorrectly. This CL guards against this by using hasOwnProperty() to ensure that only own properties are a concern. Fixes angular#8068
Previously, properties (typically functions) in the prototype chain (Object.prototype) would shadow query parameters, and cause them to be serialized incorrectly. This CL guards against this by using hasOwnProperty() to ensure that only own properties are a concern. Closes angular#8070 Fixes angular#8068
Previously, properties (typically functions) in the prototype chain (Object.prototype) would shadow query parameters, and cause them to be serialized incorrectly. This CL guards against this by using hasOwnProperty() to ensure that only own properties are a concern. Closes angular#8070 Fixes angular#8068
Thanks a lot caitp. So what is the next step? How do I know when this has been incorporated into a 1.2 hotfix? |
This was merged last week, @mattsavino --- I am not sure if we're releasing 1.2 this/next week, but it's a pretty easy patch to apply manually in the mean time. In any case this will be available soon |
Previously, properties (typically functions) in the prototype chain (Object.prototype) would shadow query parameters, and cause them to be serialized incorrectly. This CL guards against this by using hasOwnProperty() to ensure that only own properties are a concern. Closes angular#8070 Fixes angular#8068
In Firefox only, this line of code: $location.path(window.location.pathname).search('watch=online');
Produces this output in the browser:
http://local.xxx.com/entertainment?watch=function%20watch%28%29%20{%0A%20%20%20%20[native%20code]%0A}&watch=online
Notice the two watch params. I think one is somehow picking up a $scope.watch() function. This line is contained within a $scope.watch function itself.
However if we change the query parameter name to anything else, like watch2 or Watch, the output comes as expected.
$location.path(window.location.pathname).search('Watch=online');
http://local.xxx.com/entertainment?Watch=online
Here is the full function:
$scope.$watch('filters', function(newValue, oldValue){
if(!_.isEqual(oldValue, newValue)){
// update url based on selected filters when it's not deeplinking
$location.path(window.location.pathname).search('Watch=online');
}
}, true);
FYI - I also tried just setting the search manually using window.location.search = 'watch=online'. That works but also reloads the page as expected. What happens next is interesting - angular once again sees the url and adds the second watch param - with the same native function property.
The text was updated successfully, but these errors were encountered: