-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Angular.merge() fails on scope merge #12653
Comments
Difficult case. I think in that case the doctrine applies that the angular.* functions are not universal and should not be adjusted for every use case. Imo We should document this clearly and not support merging scopes. |
What would be the behavior of merge then? It would just skip that property? Would it be bad to just set a reference to the scope on the new object? I understand what your saying that the angular.* functions aren't meant to be universal. But it seems like a fairly trivial operation to set a reference to the scope in my opinion. |
IMO, setting a reference to the scope is not the correct behaviour, since I would prefer throwing an error (same as |
@gkalpak okay. I agree. Setting a reference isn't extending it. |
Adding support for scopes and merge can cause more issues than what it solves. What should happen if the source and the target are scopes? Now, the current error is not the best and would be nice if someone wants to create a PR that would throw a better error when a scope is found |
This function has problems with special object types but since it's not used in core, it is not worth implementing fixes for these cases. A general purpose library like lodash (provides `merge`) should be used instead. Closes angular#12653 Closes angular#14941 Closes angular#15180 Closes angular#15992
This function has problems with special object types but since it's not used in core, it is not worth implementing fixes for these cases. A general purpose library like lodash (provides `merge`) should be used instead. Closes angular#12653 Closes angular#14941 Closes angular#15180 Closes angular#15992
When performing angular.merge() on an object containing a $scope it fails with
"RangeError: Maximum call stack size exceeded"
.Merge() is attempting to deep copy the scope. Which just doesn't work. Angular.copy() states that copying states is not supported.
I was going to submit a PR but i'm not quite sure what the behavior should be. Should it just set a reference to the scope on the new object? (this is what I, as a user, would prefer) or skip it? Whatever it is I don't think it should throw an exception
CodePen:
http://codepen.io/anon/pen/eNwxYj
This has been handled with Dates and RegExp in the following issues:
#12409 #11974 #11720 #10519
The text was updated successfully, but these errors were encountered: