Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(tabs): cleans up label/template fetch logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Messerle committed Apr 15, 2015
1 parent bde2463 commit 17aecd2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/components/tabs/js/tabDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 17aecd2

Please sign in to comment.