From 17aecd2dbc3acfe48006ff5adb12cad5e15aa70b Mon Sep 17 00:00:00 2001 From: Robert Messerle Date: Wed, 15 Apr 2015 11:59:09 -0700 Subject: [PATCH] fix(tabs): cleans up label/template fetch logic --- src/components/tabs/js/tabDirective.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/tabs/js/tabDirective.js b/src/components/tabs/js/tabDirective.js index 9ae3843ffbd..849c2d8196d 100644 --- a/src/components/tabs/js/tabDirective.js +++ b/src/components/tabs/js/tabDirective.js @@ -87,14 +87,25 @@ scope.$on('$destroy', function () { ctrl.removeTab(data); }); function getLabel () { - return attr.label || (element.find('md-tab-label')[0] || element[0]).innerHTML; + var label = attr.label || (element.find('md-tab-label')[0] || element[0]).innerHTML; + return getLabelAttribute() || getLabelElement() || getElementContents(); + function getLabelAttribute () { return attr.label; } + function getLabelElement () { + var label = element.find('md-tab-label'); + if (label.length) return label.remove().html(); + } + function getElementContents () { + var html = element.html(); + element.empty(); + return html; + } } function getTemplate () { var content = element.find('md-tab-template'), template = content.length ? content.html() : attr.label ? element.html() : null; if (content.length) content.remove(); - else element.empty(); + else if (attr.label) element.empty(); return template; } }