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

Commit

Permalink
fix(dialog): allow Confirm dialogs to have empty/undefined content
Browse files Browse the repository at this point in the history
Fixes #4429.
  • Loading branch information
ThomasBurleson committed Sep 3, 2015
1 parent 7c4fc72 commit ffbcff3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ function MdDialogProvider($$interimElementProvider) {
function wrapSimpleContent() {
if ( controller ) {
var HTML_END_TAG = /<\/[\w-]*>/gm;
var content = controller.content;
var content = controller.content || "";

var hasHTML = HTML_END_TAG.test(content);
if (!hasHTML) {
Expand Down
36 changes: 36 additions & 0 deletions src/components/dialog/dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,42 @@ describe('$mdDialog', function() {
'ok', 'targetEvent', 'theme'
]);

it('shows a basic confirm dialog without content', inject(function($animate, $rootScope, $mdDialog) {
var parent = angular.element('<div>');
var resolved = false;

$mdDialog.show(
$mdDialog
.confirm()
.parent(parent)
.title('')
.ok('Next')
.cancel("Back")
).then(function() {
resolved = true;
});

$rootScope.$apply();
runAnimation();

var mdContainer = angular.element(parent[0].querySelector('.md-dialog-container'));
var mdDialog = mdContainer.find('md-dialog');
var mdContent = mdDialog.find('md-dialog-content');
var title = mdContent.find('h2');
var content = mdContent.find('p');
var buttons = parent.find('md-button');

expect(title.text()).toBe('');
expect(content.text()).toBe('');

buttons.eq(0).triggerHandler('click');

$rootScope.$apply();
runAnimation();

expect(resolved).toBe(true);
}));

it('shows a basic alert dialog', inject(function($animate, $rootScope, $mdDialog, $mdConstant) {
var parent = angular.element('<div>');
var resolved = false;
Expand Down

0 comments on commit ffbcff3

Please sign in to comment.