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

Commit

Permalink
fix(subheader): theme is applied to sticky clone
Browse files Browse the repository at this point in the history
Fixes #2093.
Themes were not copied to the sticky header clone.

Closes #2779. Fixes #2093.
  • Loading branch information
matthewrfindley authored and ThomasBurleson committed May 22, 2015
1 parent ae9911b commit e92686f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/subheader/subheader.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ function MdSubheaderDirective($mdSticky, $compile, $mdTheming) {
'</div>' +
'</h2>',
compile: function(element, attr, transclude) {
var outerHTML = element[0].outerHTML;
return function postLink(scope, element, attr) {
$mdTheming(element);
var outerHTML = element[0].outerHTML;

function getContent(el) {
return angular.element(el[0].querySelector('.md-subheader-content'));
}
Expand All @@ -70,7 +71,6 @@ function MdSubheaderDirective($mdSticky, $compile, $mdTheming) {
if (!element.hasClass('md-no-sticky')) {
transclude(scope, function(clone) {
var stickyClone = $compile(angular.element(outerHTML))(scope);
$mdTheming(stickyClone);
getContent(stickyClone).append(clone);
$mdSticky(scope, element, stickyClone);
});
Expand Down
8 changes: 8 additions & 0 deletions src/components/subheader/subheader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ describe('mdSubheader', function() {
expect($mdStickyMock.args[0]).toBe(scope);
}));

it('should apply the theme to the header and clone', inject(function($compile, $rootScope) {
var scope = $rootScope.$new();
$compile('<div md-theme="somethingElse">' + basicHtml + '</div>')(scope);
var element = $mdStickyMock.args[1];
var clone = $mdStickyMock.args[2];
expect(element.hasClass('md-somethingElse-theme')).toBe(true);
expect(clone.hasClass('md-somethingElse-theme')).toBe(true);
}));
});

0 comments on commit e92686f

Please sign in to comment.