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

Commit

Permalink
refactor(dialog): remove deprecated content options and methods
Browse files Browse the repository at this point in the history
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.'
  });
```
  • Loading branch information
Splaktar committed Jul 27, 2020
1 parent 00a50de commit e3b52a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
12 changes: 5 additions & 7 deletions src/components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,17 +561,17 @@ function MdDialogProvider($$interimElementProvider) {
options: dialogDefaultOptions
})
.addPreset('alert', {
methods: ['title', 'htmlContent', 'textContent', 'content', 'ariaLabel', 'ok', 'theme',
methods: ['title', 'htmlContent', 'textContent', 'ariaLabel', 'ok', 'theme',
'css'],
options: advancedDialogOptions
})
.addPreset('confirm', {
methods: ['title', 'htmlContent', 'textContent', 'content', 'ariaLabel', 'ok', 'cancel',
methods: ['title', 'htmlContent', 'textContent', 'ariaLabel', 'ok', 'cancel',
'theme', 'css'],
options: advancedDialogOptions
})
.addPreset('prompt', {
methods: ['title', 'htmlContent', 'textContent', 'initialValue', 'content', 'placeholder', 'ariaLabel',
methods: ['title', 'htmlContent', 'textContent', 'initialValue', 'placeholder', 'ariaLabel',
'ok', 'cancel', 'theme', 'css', 'required'],
options: advancedDialogOptions
});
Expand Down Expand Up @@ -698,8 +698,7 @@ function MdDialogProvider($$interimElementProvider) {

if (controller) {
var mdHtmlContent = controller.htmlContent || options.htmlContent || '';
var mdTextContent = controller.textContent || options.textContent ||
controller.content || options.content || '';
var mdTextContent = controller.textContent || options.textContent || '';

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

/**
* For alerts, focus on content... otherwise focus on
* the close button (or equivalent)
* For alerts, focus on content... otherwise focus on the close button (or equivalent)
*/
function focusOnOpen() {
if (options.focusOnOpen) {
Expand Down
28 changes: 3 additions & 25 deletions src/components/dialog/dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ describe('$mdDialog', function() {

describe('#alert()', function() {
hasConfigurationMethods('alert', [
'title', 'htmlContent', 'textContent', 'ariaLabel',
'ok', 'targetEvent', 'theme'
'title', 'htmlContent', 'textContent', 'ariaLabel', 'ok', 'targetEvent', 'theme'
]);

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

describe('#confirm()', function() {
hasConfigurationMethods('confirm', [
'title', 'htmlContent', 'textContent', 'ariaLabel',
'ok', 'cancel', 'targetEvent', 'theme'
'title', 'htmlContent', 'textContent', 'ariaLabel', 'ok', 'cancel', 'targetEvent', 'theme'
]);

it('shows a basic confirm dialog with simple text content', inject(function($rootScope, $mdDialog) {
Expand Down Expand Up @@ -405,26 +403,6 @@ 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 Expand Up @@ -674,7 +652,7 @@ describe('$mdDialog', function() {

describe('#prompt()', function() {
hasConfigurationMethods('prompt', ['title', 'htmlContent', 'textContent',
'content', 'placeholder', 'ariaLabel', 'ok', 'cancel', 'theme', 'css'
'placeholder', 'ariaLabel', 'ok', 'cancel', 'theme', 'css'
]);

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

0 comments on commit e3b52a0

Please sign in to comment.