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

Commit

Permalink
fix(interimElement): add fallback to document.body if root node removed
Browse files Browse the repository at this point in the history
closes #2343
  • Loading branch information
rschmukler committed Apr 16, 2015
1 parent e0005fc commit 3b3d020
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/services/interimElement/interimElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ function InterimElementProvider() {
if (!(options.parent || {}).length) {
options.parent = $rootElement.find('body');
if (!options.parent.length) options.parent = $rootElement;
if (options.parent[0].nodeName == '#comment') {
options.parent = $document.find('body');
}
}

if (options.themable) $mdTheming(element);
Expand Down
16 changes: 16 additions & 0 deletions src/core/services/interimElement/interimElement.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,22 @@ describe('$$interimElement service', function() {
expect(shown).toBe(true);
}));

it('falls back to $document.body if $rootElement was removed', inject(function($document, $rootElement, $rootScope) {
var shown = false;
var originalRoot = $rootElement[0];
var commentEl = angular.element('<!-- I am a comment -->');
$rootElement[0] = commentEl[0];
Service.show({
onShow: function(scope, element, options) {
expect(options.parent[0]).toBe($document[0].body);
shown = true;
}
});
$rootScope.$digest();
$rootElement[0] = originalRoot;
expect(shown).toBe(true);
}));

it('allows parent reference', inject(function($rootScope) {
var parent = angular.element('<div>');

Expand Down

0 comments on commit 3b3d020

Please sign in to comment.