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

Commit ffbcff3

Browse files
fix(dialog): allow Confirm dialogs to have empty/undefined content
Fixes #4429.
1 parent 7c4fc72 commit ffbcff3

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/components/dialog/dialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ function MdDialogProvider($$interimElementProvider) {
511511
function wrapSimpleContent() {
512512
if ( controller ) {
513513
var HTML_END_TAG = /<\/[\w-]*>/gm;
514-
var content = controller.content;
514+
var content = controller.content || "";
515515

516516
var hasHTML = HTML_END_TAG.test(content);
517517
if (!hasHTML) {

src/components/dialog/dialog.spec.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,42 @@ describe('$mdDialog', function() {
3030
'ok', 'targetEvent', 'theme'
3131
]);
3232

33+
it('shows a basic confirm dialog without content', inject(function($animate, $rootScope, $mdDialog) {
34+
var parent = angular.element('<div>');
35+
var resolved = false;
36+
37+
$mdDialog.show(
38+
$mdDialog
39+
.confirm()
40+
.parent(parent)
41+
.title('')
42+
.ok('Next')
43+
.cancel("Back")
44+
).then(function() {
45+
resolved = true;
46+
});
47+
48+
$rootScope.$apply();
49+
runAnimation();
50+
51+
var mdContainer = angular.element(parent[0].querySelector('.md-dialog-container'));
52+
var mdDialog = mdContainer.find('md-dialog');
53+
var mdContent = mdDialog.find('md-dialog-content');
54+
var title = mdContent.find('h2');
55+
var content = mdContent.find('p');
56+
var buttons = parent.find('md-button');
57+
58+
expect(title.text()).toBe('');
59+
expect(content.text()).toBe('');
60+
61+
buttons.eq(0).triggerHandler('click');
62+
63+
$rootScope.$apply();
64+
runAnimation();
65+
66+
expect(resolved).toBe(true);
67+
}));
68+
3369
it('shows a basic alert dialog', inject(function($animate, $rootScope, $mdDialog, $mdConstant) {
3470
var parent = angular.element('<div>');
3571
var resolved = false;

0 commit comments

Comments
 (0)