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

Commit 5551699

Browse files
feat(dialog): allow specifying parent by string selector.
1 parent 6681e82 commit 5551699

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/components/dialog/dialog.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,6 @@ function MdDialogProvider($$interimElementProvider) {
463463
* Show method for dialogs
464464
*/
465465
function onShow(scope, element, options, controller) {
466-
element = $mdUtil.extractElementByName(element, 'md-dialog');
467466
angular.element($document[0].body).addClass('md-dialog-is-showing');
468467

469468
wrapSimpleContent();
@@ -549,8 +548,11 @@ function MdDialogProvider($$interimElementProvider) {
549548
* unless overridden in the options.parent
550549
*/
551550
function captureSourceAndParent(element, options) {
552-
var origin = {element: null, bounds: null, focus: angular.noop};
553-
options.origin = angular.extend({}, origin, options.origin || {});
551+
options.origin = angular.extend({
552+
element: null,
553+
bounds: null,
554+
focus: angular.noop
555+
}, options.origin || {});
554556

555557
var source = angular.element((options.targetEvent || {}).target);
556558
if (source && source.length) {
@@ -564,7 +566,14 @@ function MdDialogProvider($$interimElementProvider) {
564566
}
565567
}
566568

567-
// In case the user provides a raw dom element, always wrap it in jqLite
569+
// If the parent specifier is a simple string selector, then query for
570+
// the DOM element.
571+
if ( angular.isString(options.parent) ) {
572+
var simpleSelector = options.parent;
573+
container = $document[0].querySelectorAll(selector);
574+
options.parent = container.length ? container[0] : null;
575+
}
576+
// If we have a reference to a raw dom element, always wrap it in jqLite
568577
options.parent = angular.element(options.parent || $rootElement);
569578

570579
}

0 commit comments

Comments
 (0)