diff --git a/src/components/dialog/dialog.js b/src/components/dialog/dialog.js index c5582f4e82b..14af4759e94 100644 --- a/src/components/dialog/dialog.js +++ b/src/components/dialog/dialog.js @@ -463,7 +463,6 @@ function MdDialogProvider($$interimElementProvider) { * Show method for dialogs */ function onShow(scope, element, options, controller) { - element = $mdUtil.extractElementByName(element, 'md-dialog'); angular.element($document[0].body).addClass('md-dialog-is-showing'); wrapSimpleContent(); @@ -549,8 +548,11 @@ function MdDialogProvider($$interimElementProvider) { * unless overridden in the options.parent */ function captureSourceAndParent(element, options) { - var origin = {element: null, bounds: null, focus: angular.noop}; - options.origin = angular.extend({}, origin, options.origin || {}); + options.origin = angular.extend({ + element: null, + bounds: null, + focus: angular.noop + }, options.origin || {}); var source = angular.element((options.targetEvent || {}).target); if (source && source.length) { @@ -564,7 +566,14 @@ function MdDialogProvider($$interimElementProvider) { } } - // In case the user provides a raw dom element, always wrap it in jqLite + // If the parent specifier is a simple string selector, then query for + // the DOM element. + if ( angular.isString(options.parent) ) { + var simpleSelector = options.parent; + container = $document[0].querySelectorAll(selector); + options.parent = container.length ? container[0] : null; + } + // If we have a reference to a raw dom element, always wrap it in jqLite options.parent = angular.element(options.parent || $rootElement); }