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

Commit 4b24259

Browse files
committed
chore(dialog): re-add (deprecated) content method for alert() and
confirm(). Fixes #5790
1 parent adb2281 commit 4b24259

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/components/dialog/dialog.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -424,15 +424,18 @@ function MdDialogProvider($$interimElementProvider) {
424424

425425
return $$interimElementProvider('$mdDialog')
426426
.setDefaults({
427-
methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose', 'targetEvent', 'closeTo', 'openFrom', 'parent', 'fullscreen'],
427+
methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose',
428+
'targetEvent', 'closeTo', 'openFrom', 'parent', 'fullscreen'],
428429
options: dialogDefaultOptions
429430
})
430431
.addPreset('alert', {
431-
methods: ['title', 'htmlContent', 'textContent', 'ariaLabel', 'ok', 'theme', 'css'],
432+
methods: ['title', 'htmlContent', 'textContent', 'content', 'ariaLabel', 'ok', 'theme',
433+
'css'],
432434
options: advancedDialogOptions
433435
})
434436
.addPreset('confirm', {
435-
methods: ['title', 'htmlContent', 'textContent', 'ariaLabel', 'ok', 'cancel', 'theme', 'css'],
437+
methods: ['title', 'htmlContent', 'textContent', 'content', 'ariaLabel', 'ok', 'cancel',
438+
'theme', 'css'],
436439
options: advancedDialogOptions
437440
});
438441

@@ -510,7 +513,8 @@ function MdDialogProvider($$interimElementProvider) {
510513
function beforeShow(scope, element, options, controller) {
511514
if (controller) {
512515
controller.mdHtmlContent = controller.htmlContent || options.htmlContent || '';
513-
controller.mdTextContent = controller.textContent || options.textContent || '';
516+
controller.mdTextContent = controller.textContent || options.textContent ||
517+
controller.content || options.content || '';
514518

515519
if (controller.mdHtmlContent && !$injector.has('$sanitize')) {
516520
throw Error('The ngSanitize module must be loaded in order to use htmlContent.');

src/components/dialog/dialog.spec.js

+20
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,26 @@ describe('$mdDialog', function() {
256256
expect(content.text()).toBe('Choose');
257257
}));
258258

259+
it('should support the deprecated `content` method as text', inject(function($mdDialog) {
260+
var parent = angular.element('<div>');
261+
262+
$mdDialog.show(
263+
$mdDialog.confirm({
264+
parent: parent,
265+
ok: 'Next',
266+
cancel: 'Back',
267+
title: 'Which Way ',
268+
content: '<div class="mine">Choose</div>'
269+
})
270+
);
271+
272+
runAnimation();
273+
274+
var contentBody = parent[0].querySelector('.md-dialog-content-body');
275+
276+
expect(contentBody.textContent).toBe('<div class="mine">Choose</div>');
277+
}));
278+
259279
it('should NOT allow custom elements in confirm htmlContent', inject(function($mdDialog) {
260280
var parent = angular.element('<div>');
261281

0 commit comments

Comments
 (0)