Skip to content

Commit

Permalink
Merge pull request #536 from hannu/fix-fullscreen-encaps
Browse files Browse the repository at this point in the history
Fix fullscreen mode when using disableEncapsulation option
  • Loading branch information
junaidrsd committed Mar 30, 2015
2 parents 0d273b1 + 67fc5a6 commit 542935e
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions lib/app/js/directives/shadowDom.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,26 @@ angular.module('sgApp')
restrict: 'E',
transclude: true,
link: function(scope, element, attrs, controller, transclude) {
if (typeof element[0].createShadowRoot === 'function' && !Styleguide.config.data.disableEncapsulation) {
var root = angular.element(element[0].createShadowRoot());
root.append($templateCache.get(USER_STYLES_TEMPLATE));
transclude(function(clone) {
root.append(clone);
});
} else {
transclude(function(clone) {
element.append(clone);
});
}

scope.$watch(function() {
return Styleguide.config;
}, function() {
if (typeof element[0].createShadowRoot === 'function' && (Styleguide.config && Styleguide.config.data && !Styleguide.config.data.disableEncapsulation)) {
angular.element(element[0]).empty();
var root = angular.element(element[0].createShadowRoot());
root.append($templateCache.get(USER_STYLES_TEMPLATE));
transclude(function(clone) {
root.append(clone);
});
} else {
transclude(function(clone) {
var root = angular.element(element[0]);
root.empty();
root.append(clone);
});
}
}, true);

}
};
});

0 comments on commit 542935e

Please sign in to comment.