Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

fix(modal): cannot append to element outside of document #4818

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])

function removeModalWindow(modalInstance, elementToReceiveFocus) {
var modalWindow = openedWindows.get(modalInstance).value;
var appendToElement = $document.find(modalWindow.appendTo).eq(0);
var appendToElement = modalWindow.appendTo;

//clean up the stack
openedWindows.remove(modalInstance);
Expand Down Expand Up @@ -424,7 +424,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])

openedClasses.put(modalBodyClass, modalInstance);

var appendToElement = $document.find(modal.appendTo).eq(0),
var appendToElement = modal.appendTo,
currBackdropIndex = backdropIndex();

if (!appendToElement.length) {
Expand Down Expand Up @@ -565,8 +565,8 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
backdrop: true, //can also be false or 'static'
keyboard: true
},
$get: ['$injector', '$rootScope', '$q', '$templateRequest', '$controller', '$uibModalStack',
function ($injector, $rootScope, $q, $templateRequest, $controller, $modalStack) {
$get: ['$injector', '$rootScope', '$q', '$document', '$templateRequest', '$controller', '$uibModalStack',
function ($injector, $rootScope, $q, $document, $templateRequest, $controller, $modalStack) {
var $modal = {};

function getTemplatePromise(options) {
Expand Down Expand Up @@ -614,7 +614,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
//merge and clean up options
modalOptions = angular.extend({}, $modalProvider.options, modalOptions);
modalOptions.resolve = modalOptions.resolve || {};
modalOptions.appendTo = modalOptions.appendTo || 'body';
modalOptions.appendTo = modalOptions.appendTo || $document.find('body').eq(0);

//verify options
if (!modalOptions.template && !modalOptions.templateUrl) {
Expand Down