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

Commit

Permalink
chore(dialog): re-add (deprecated) content method for alert() and
Browse files Browse the repository at this point in the history
confirm(). Fixes #5790
  • Loading branch information
jelbourn committed Dec 1, 2015
1 parent adb2281 commit 4b24259
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,18 @@ function MdDialogProvider($$interimElementProvider) {

return $$interimElementProvider('$mdDialog')
.setDefaults({
methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose', 'targetEvent', 'closeTo', 'openFrom', 'parent', 'fullscreen'],
methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose',
'targetEvent', 'closeTo', 'openFrom', 'parent', 'fullscreen'],
options: dialogDefaultOptions
})
.addPreset('alert', {
methods: ['title', 'htmlContent', 'textContent', 'ariaLabel', 'ok', 'theme', 'css'],
methods: ['title', 'htmlContent', 'textContent', 'content', 'ariaLabel', 'ok', 'theme',
'css'],
options: advancedDialogOptions
})
.addPreset('confirm', {
methods: ['title', 'htmlContent', 'textContent', 'ariaLabel', 'ok', 'cancel', 'theme', 'css'],
methods: ['title', 'htmlContent', 'textContent', 'content', 'ariaLabel', 'ok', 'cancel',
'theme', 'css'],
options: advancedDialogOptions
});

Expand Down Expand Up @@ -510,7 +513,8 @@ function MdDialogProvider($$interimElementProvider) {
function beforeShow(scope, element, options, controller) {
if (controller) {
controller.mdHtmlContent = controller.htmlContent || options.htmlContent || '';
controller.mdTextContent = controller.textContent || options.textContent || '';
controller.mdTextContent = controller.textContent || options.textContent ||
controller.content || options.content || '';

if (controller.mdHtmlContent && !$injector.has('$sanitize')) {
throw Error('The ngSanitize module must be loaded in order to use htmlContent.');
Expand Down
20 changes: 20 additions & 0 deletions src/components/dialog/dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,26 @@ describe('$mdDialog', function() {
expect(content.text()).toBe('Choose');
}));

it('should support the deprecated `content` method as text', inject(function($mdDialog) {
var parent = angular.element('<div>');

$mdDialog.show(
$mdDialog.confirm({
parent: parent,
ok: 'Next',
cancel: 'Back',
title: 'Which Way ',
content: '<div class="mine">Choose</div>'
})
);

runAnimation();

var contentBody = parent[0].querySelector('.md-dialog-content-body');

expect(contentBody.textContent).toBe('<div class="mine">Choose</div>');
}));

it('should NOT allow custom elements in confirm htmlContent', inject(function($mdDialog) {
var parent = angular.element('<div>');

Expand Down

0 comments on commit 4b24259

Please sign in to comment.