Skip to content

Commit 732850a

Browse files
Use .html() instead of .textContents
1 parent 41d3918 commit 732850a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/directive.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ angular.module('gettext').directive('translate', function (gettextCatalog, $pars
5959

6060
var oldContents = element.contents();
6161

62+
if(!oldContents){
63+
return;
64+
}
65+
6266
// Avoid redundant swaps
63-
if (translated === oldContents[0].textContent){
67+
if (translated === oldContents.html()){
6468
// Take care of unlinked content
6569
if (linking){
6670
$compile(oldContents)(scope);
@@ -73,8 +77,13 @@ angular.module('gettext').directive('translate', function (gettextCatalog, $pars
7377
$compile(newWrapper.contents())(scope);
7478
var newContents = newWrapper.contents();
7579

76-
$animate.enter(newContents, element);
77-
$animate.leave(oldContents);
80+
// No animation is required before anything shows
81+
if (linking){
82+
oldContents.replaceWith(newContents);
83+
} else {
84+
$animate.enter(newContents, element);
85+
$animate.leave(oldContents);
86+
}
7887
}
7988

8089
if (attrs.translateN) {

0 commit comments

Comments
 (0)