addElementTransformer after setTransformOnlyServerElements(true) results in local objects still getting transformed in 1.4.0.
For example:
angular.module('app', ['restangular']).run(["Restangular", function (Restangular) {
Restangular.setTransformOnlyServerElements(true);
Restangular.addElementTransformer('items', false, function(obj) {
if (!obj.fromServer) {
console.debug("I wouldn't expect to get here");
}
return obj;
});
Restangular.one('items',0).get().then(function(c) {
//do something.
});
}]);
If you run this code, you'll see that you do in fact get local object in the transform callback. This appears to only be the case in 1.4.0, because I run the same code in 1.3.1 just fine.
This appears to be because the call for transformElem added a new parameter force:
config.transformElem = function(elem, isCollection, route, Restangular, force)
This value is hardcoded to be true in both of the restangularizeElem and restangularizeCollection methods.
It appears this change came from https://github.com/mgonto/restangular/issues/581 but callbacks to both addElementTransformer and extendModelalso go through the restangularizeElem and restangularizeCollection functions
Edit: fixed a typo.
@mgonto can you confirm this issue occurred because of your change?
Can you verify that this is still broken in 1.5.2?
@daviesgeek, I can confirm this is still broken in 1.5.2 as well as 1.6.1