Skip to content

Commit 135d63a

Browse files
Early return when contents is empty
1 parent d452ccb commit 135d63a

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

dist/angular-gettext.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,12 @@ angular.module('gettext').directive('translate', ["gettextCatalog", "$parse", "$
192192

193193
var oldContents = element.contents();
194194

195-
// if (!oldContents.length){
196-
// $compile(oldContents)(scope);
197-
// return;
198-
// }
195+
if (oldContents.length === 0){
196+
return;
197+
}
199198

200199
// Avoid redundant swaps
201-
if (translated === oldContents.html()){
200+
if (translated === trim(oldContents.html())){
202201
// Take care of unlinked content
203202
if (linking){
204203
$compile(oldContents)(scope);

dist/angular-gettext.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/directive.js

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

6060
var oldContents = element.contents();
6161

62+
if (oldContents.length === 0){
63+
return;
64+
}
65+
6266
// Avoid redundant swaps
6367
if (translated === trim(oldContents.html())){
6468
// Take care of unlinked content

0 commit comments

Comments
 (0)