-
Notifications
You must be signed in to change notification settings - Fork 1k
TypeError: Cannot call method 'trim' of undefined
in $translate directive
#298
Comments
Oh well.. I had actually reviewed 4939424 but thought that could not be happened. Should be more pessimistic. @PascalPrecht Fix both? |
@knalli I see your commit, but isn't the whole problem that it gets called with |
yeah, but that one was the one which crashed the stuff internally and should be avoided. @PascalPrecht I'm not sure whether the stricter condition of 08f087b will made the unwatch() still good enough. Otherwise, this should be fixed. Actually, the bug is because scope.$watch('interpolateParams', function (value) { |
@knalli if there are no interpolateParams it actually should be undefined, shouldn't it? |
it's an empty object, actually. |
@PascalPrecht @knalli Any news here? Any way we can help? We also noticed the empty object, that still yields true in js, maybe that's the error? |
Let's wait for @PascalPrecht because I'm quite not sure what the intent of the change was. |
Okay, that was some kind of optimization. So, actually, scope.$watch('interpolateParams', function (value) {
if (scope.translationId && value) {
iElement.html(translate(scope.translationId, value, translateInterpolation));
}
}, true); should be scope.$watch('interpolateParams', function (value) {
if (scope.translationId) {
iElement.html(translate(scope.translationId, value, translateInterpolation));
}
}, true); because
imho |
ping @PascalPrecht |
Reapplied @knalli 's patch in |
With the latest canary version of this module we're seeing getting
TypeError: Cannot call method 'trim' of undefined
errors. We've been able to track the error down to the directive when bothtranslate
andtranslate-values
are used, but only if they're used on elements within anng-switch
(I know right 👍).The error can be seen here: http://jsfiddle.net/uyjLS/.
After this line it is possible for the
scope.translationId
to be undefined: here. In master there was a check for that here. This is the commit that changed it: 3b1d1c6.We've now fixed it locally by checking
if (value && scope.translationId)
, but we're not sure if this is the right way to fix it and we don't know how to write an appropriate test for it. Another thing we notice is that in the "failure" case it seems thatvalue
is{}
.Hope you guys know what is happening and we're interested in seeing the actual fix so we can do it ourselves next time! :)
The text was updated successfully, but these errors were encountered: