@@ -562,7 +562,7 @@ function MdDialogProvider($$interimElementProvider) {
562
562
return $$interimElementProvider ( '$mdDialog' )
563
563
. setDefaults ( {
564
564
methods : [ 'disableParentScroll' , 'hasBackdrop' , 'clickOutsideToClose' , 'escapeToClose' ,
565
- 'targetEvent' , 'closeTo' , 'openFrom' , 'parent' , 'fullscreen' , 'contentElement' ] ,
565
+ 'targetEvent' , 'closeTo' , 'openFrom' , 'parent' , 'fullscreen' ] ,
566
566
options : dialogDefaultOptions
567
567
} )
568
568
. addPreset ( 'alert' , {
@@ -647,7 +647,6 @@ function MdDialogProvider($$interimElementProvider) {
647
647
clickOutsideToClose : false ,
648
648
escapeToClose : true ,
649
649
targetEvent : null ,
650
- contentElement : null ,
651
650
closeTo : null ,
652
651
openFrom : null ,
653
652
focusOnOpen : true ,
@@ -679,10 +678,6 @@ function MdDialogProvider($$interimElementProvider) {
679
678
// Those option changes need to be done, before the compilation has started, because otherwise
680
679
// the option changes will be not available in the $mdCompilers locales.
681
680
detectTheming ( options ) ;
682
-
683
- if ( options . contentElement ) {
684
- options . restoreContentElement = installContentElement ( options ) ;
685
- }
686
681
}
687
682
688
683
function beforeShow ( scope , element , options , controller ) {
@@ -799,14 +794,15 @@ function MdDialogProvider($$interimElementProvider) {
799
794
*/
800
795
function detachAndClean ( ) {
801
796
angular . element ( $document [ 0 ] . body ) . removeClass ( 'md-dialog-is-showing' ) ;
802
- // Only remove the element, if it's not provided through the contentElement option.
803
- if ( ! options . contentElement ) {
804
- element . remove ( ) ;
805
- } else {
797
+
798
+ // Reverse the container stretch if using a content element.
799
+ if ( options . contentElement ) {
806
800
options . reverseContainerStretch ( ) ;
807
- options . restoreContentElement ( ) ;
808
801
}
809
802
803
+ // Exposed cleanup function from the $mdCompiler.
804
+ options . cleanupElement ( ) ;
805
+
810
806
if ( ! options . $destroy ) options . origin . focus ( ) ;
811
807
}
812
808
}
@@ -827,56 +823,6 @@ function MdDialogProvider($$interimElementProvider) {
827
823
828
824
}
829
825
830
- /**
831
- * Installs a content element to the current $$interimElement provider options.
832
- * @returns {Function } Function to restore the content element at its old DOM location.
833
- */
834
- function installContentElement ( options ) {
835
- var contentEl = options . contentElement ;
836
- var restoreFn = null ;
837
-
838
- if ( angular . isString ( contentEl ) ) {
839
- contentEl = document . querySelector ( contentEl ) ;
840
- restoreFn = createRestoreFn ( contentEl ) ;
841
- } else {
842
- contentEl = contentEl [ 0 ] || contentEl ;
843
-
844
- // When the element is visible in the DOM, then we restore it at close of the dialog.
845
- // Otherwise it will be removed from the DOM after close.
846
- if ( document . contains ( contentEl ) ) {
847
- restoreFn = createRestoreFn ( contentEl ) ;
848
- } else {
849
- restoreFn = function ( ) {
850
- contentEl . parentNode . removeChild ( contentEl ) ;
851
- }
852
- }
853
- }
854
-
855
- // Overwrite the options to use the content element.
856
- options . element = angular . element ( contentEl ) ;
857
- options . skipCompile = true ;
858
-
859
- return restoreFn ;
860
-
861
- function createRestoreFn ( element ) {
862
- var parent = element . parentNode ;
863
- var nextSibling = element . nextElementSibling ;
864
-
865
- return function ( ) {
866
- if ( ! nextSibling ) {
867
- // When the element didn't had any sibling, then it can be simply appended to the
868
- // parent, because it plays no role, which index it had before.
869
- parent . appendChild ( element ) ;
870
- } else {
871
- // When the element had a sibling, which marks the previous position of the element
872
- // in the DOM, we insert it correctly before the sibling, to have the same index as
873
- // before.
874
- parent . insertBefore ( element , nextSibling ) ;
875
- }
876
- }
877
- }
878
- }
879
-
880
826
/**
881
827
* Capture originator/trigger/from/to element information (if available)
882
828
* and the parent container for the dialog; defaults to the $rootElement
0 commit comments