-
Notifications
You must be signed in to change notification settings - Fork 831
Open
Description
Hi,
I have a corner case with a route called "watch" and Firefox.
Here's the relevant code from Restangular 1.4.0:
config.transformElem = function(elem, isCollection, route, Restangular, force) {
if (!force && !config.transformLocalElements && !elem[config.restangularFields.fromServer]) {
return elem;
}
var typeTransformers = config.transformers[route];
var changedElem = elem;
if (typeTransformers) {
_.each(typeTransformers, function(transformer) {
changedElem = transformer(isCollection, changedElem);
});
}
return config.onElemRestangularized(changedElem,
isCollection, route, Restangular);
};Besides formatting changes, the code is the same in 1.5.1.
The exact line that's the source of the issue:
var typeTransformers = config.transformers[route];What exactly goes wrong:
config.transformersis empty, i.e.,{}routeis"watch"config.transformers[route]should beundefined- instead, it's picking up Object.prototype.watch
Changing the line to:
var typeTransformers = config.hasOwnProperty(route) && config.transformers[route];would fix the problem.
Similar checks should be added everywhere the property name comes from outside Restangular.
Metadata
Metadata
Assignees
Labels
No labels