From 0f84048932559bdc1900b36d999312ae7a8145bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksander=20Blomsk=C3=B8ld?= Date: Mon, 3 Jun 2013 12:59:13 +0200 Subject: [PATCH] fix($compile): support text inside multi-element directive --- src/ng/compile.js | 4 ++-- test/ng/compileSpec.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) mode change 100644 => 100755 src/ng/compile.js diff --git a/src/ng/compile.js b/src/ng/compile.js old mode 100644 new mode 100755 index 2dddf82dcbff..9bbadd0fc839 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -591,8 +591,8 @@ function $CompileProvider($provide) { if (!node) { throw ngError(51, "Unterminated attribute, found '{0}' but no matching '{1}' found.", attrStart, attrEnd); } - if (node.hasAttribute(attrStart)) depth++; - if (node.hasAttribute(attrEnd)) depth--; + if (node.hasAttribute && node.hasAttribute(attrStart)) depth++; + if (node.hasAttribute && node.hasAttribute(attrEnd)) depth--; nodes.push(node); node = node.nextSibling; } while (depth > 0); diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 95b2ab72d93f..d5833337657a 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -2746,6 +2746,17 @@ describe('$compile', function() { expect(element.text()).toEqual('1A1B;2A2B;'); })); + it('should group on embedded text nodes', inject(function($compile, $rootScope) { + $rootScope.show = false; + element = $compile( + '
' + + '{{i}}A' + + 'X' + + '{{i}}B;' + + '
')($rootScope); + $rootScope.$digest(); + expect(element.text()).toEqual('1AX1B;2AX2B;'); + })); it('should group on $root compile function', inject(function($compile, $rootScope) { $rootScope.show = false;