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

Commit e3b52a0

Browse files
committed
refactor(dialog): remove deprecated content options and methods
BREAKING CHANGE: Removed support for the deprecated `.content('string')` methods and options. These were deprecated in favor of `.textContent('string')` and `.htmlContent('sanitized-string')'` methods and their associated options. Please note that use of `.htmlContent` requires that the `ngSanitize` module be loaded. If you have ```js alert = $mdDialog.alert() .content('This is an example.'); ``` It needs to be changed to ```js alert = $mdDialog.alert() .textContent('This is an example.'); ``` If you have ```js alert = $mdDialog.alert({ content: 'This is an example.' }); ``` It needs to be changed to ```js alert = $mdDialog.alert({ textContent: 'This is an example.' }); ```
1 parent 00a50de commit e3b52a0

File tree

2 files changed

+8
-32
lines changed

2 files changed

+8
-32
lines changed

src/components/dialog/dialog.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -561,17 +561,17 @@ function MdDialogProvider($$interimElementProvider) {
561561
options: dialogDefaultOptions
562562
})
563563
.addPreset('alert', {
564-
methods: ['title', 'htmlContent', 'textContent', 'content', 'ariaLabel', 'ok', 'theme',
564+
methods: ['title', 'htmlContent', 'textContent', 'ariaLabel', 'ok', 'theme',
565565
'css'],
566566
options: advancedDialogOptions
567567
})
568568
.addPreset('confirm', {
569-
methods: ['title', 'htmlContent', 'textContent', 'content', 'ariaLabel', 'ok', 'cancel',
569+
methods: ['title', 'htmlContent', 'textContent', 'ariaLabel', 'ok', 'cancel',
570570
'theme', 'css'],
571571
options: advancedDialogOptions
572572
})
573573
.addPreset('prompt', {
574-
methods: ['title', 'htmlContent', 'textContent', 'initialValue', 'content', 'placeholder', 'ariaLabel',
574+
methods: ['title', 'htmlContent', 'textContent', 'initialValue', 'placeholder', 'ariaLabel',
575575
'ok', 'cancel', 'theme', 'css', 'required'],
576576
options: advancedDialogOptions
577577
});
@@ -698,8 +698,7 @@ function MdDialogProvider($$interimElementProvider) {
698698

699699
if (controller) {
700700
var mdHtmlContent = controller.htmlContent || options.htmlContent || '';
701-
var mdTextContent = controller.textContent || options.textContent ||
702-
controller.content || options.content || '';
701+
var mdTextContent = controller.textContent || options.textContent || '';
703702

704703
if (mdHtmlContent && !$injector.has('$sanitize')) {
705704
throw Error('The ngSanitize module must be loaded in order to use htmlContent.');
@@ -741,8 +740,7 @@ function MdDialogProvider($$interimElementProvider) {
741740
});
742741

743742
/**
744-
* For alerts, focus on content... otherwise focus on
745-
* the close button (or equivalent)
743+
* For alerts, focus on content... otherwise focus on the close button (or equivalent)
746744
*/
747745
function focusOnOpen() {
748746
if (options.focusOnOpen) {

src/components/dialog/dialog.spec.js

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ describe('$mdDialog', function() {
3333

3434
describe('#alert()', function() {
3535
hasConfigurationMethods('alert', [
36-
'title', 'htmlContent', 'textContent', 'ariaLabel',
37-
'ok', 'targetEvent', 'theme'
36+
'title', 'htmlContent', 'textContent', 'ariaLabel', 'ok', 'targetEvent', 'theme'
3837
]);
3938

4039
it('shows a basic confirm dialog without content', inject(function($animate, $rootScope, $mdDialog) {
@@ -342,8 +341,7 @@ describe('$mdDialog', function() {
342341

343342
describe('#confirm()', function() {
344343
hasConfigurationMethods('confirm', [
345-
'title', 'htmlContent', 'textContent', 'ariaLabel',
346-
'ok', 'cancel', 'targetEvent', 'theme'
344+
'title', 'htmlContent', 'textContent', 'ariaLabel', 'ok', 'cancel', 'targetEvent', 'theme'
347345
]);
348346

349347
it('shows a basic confirm dialog with simple text content', inject(function($rootScope, $mdDialog) {
@@ -405,26 +403,6 @@ describe('$mdDialog', function() {
405403
expect(content.text()).toBe('Choose');
406404
}));
407405

408-
it('should support the deprecated `content` method as text', inject(function($mdDialog) {
409-
var parent = angular.element('<div>');
410-
411-
$mdDialog.show(
412-
$mdDialog.confirm({
413-
parent: parent,
414-
ok: 'Next',
415-
cancel: 'Back',
416-
title: 'Which Way ',
417-
content: '<div class="mine">Choose</div>'
418-
})
419-
);
420-
421-
runAnimation();
422-
423-
var contentBody = parent[0].querySelector('.md-dialog-content-body');
424-
425-
expect(contentBody.textContent).toBe('<div class="mine">Choose</div>');
426-
}));
427-
428406
it('should NOT allow custom elements in confirm htmlContent', inject(function($mdDialog) {
429407
var parent = angular.element('<div>');
430408

@@ -674,7 +652,7 @@ describe('$mdDialog', function() {
674652

675653
describe('#prompt()', function() {
676654
hasConfigurationMethods('prompt', ['title', 'htmlContent', 'textContent',
677-
'content', 'placeholder', 'ariaLabel', 'ok', 'cancel', 'theme', 'css'
655+
'placeholder', 'ariaLabel', 'ok', 'cancel', 'theme', 'css'
678656
]);
679657

680658
it('shows a basic prompt dialog', inject(function($animate, $rootScope, $mdDialog) {

0 commit comments

Comments
 (0)