aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/dialog/common-deprecated.js1
-rw-r--r--tests/unit/dialog/common.js1
-rw-r--r--tests/unit/dialog/core.js38
-rw-r--r--ui/widgets/dialog.js9
4 files changed, 48 insertions, 1 deletions
diff --git a/tests/unit/dialog/common-deprecated.js b/tests/unit/dialog/common-deprecated.js
index 1efdcb030..2cdae9681 100644
--- a/tests/unit/dialog/common-deprecated.js
+++ b/tests/unit/dialog/common-deprecated.js
@@ -34,6 +34,7 @@ common.testWidget( "dialog", {
resizable: true,
show: null,
title: null,
+ uiDialogTitleHeadingLevel: 0,
width: 300,
// Callbacks
diff --git a/tests/unit/dialog/common.js b/tests/unit/dialog/common.js
index c8d885ad0..f31181047 100644
--- a/tests/unit/dialog/common.js
+++ b/tests/unit/dialog/common.js
@@ -33,6 +33,7 @@ common.testWidget( "dialog", {
resizable: true,
show: null,
title: null,
+ uiDialogTitleHeadingLevel: 0,
width: 300,
// Callbacks
diff --git a/tests/unit/dialog/core.js b/tests/unit/dialog/core.js
index c6bdec778..a8cc9678e 100644
--- a/tests/unit/dialog/core.js
+++ b/tests/unit/dialog/core.js
@@ -117,6 +117,44 @@ QUnit.test( "aria-modal", function( assert ) {
element.remove();
} );
+QUnit.test( "ui dialog title heading level", function( assert ) {
+ assert.expect( 8 );
+
+ var element, nodeName;
+
+ element = $( "<div>" ).dialog( { modal: true } );
+ nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
+ assert.equal( nodeName, "span", "Element wrapping the dialog title is span" );
+
+ element = $( "<div>" ).dialog( { modal: true, uiDialogTitleHeadingLevel: 0 } );
+ nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
+ assert.equal( nodeName, "span", "Element wrapping the dialog title is span" );
+
+ element = $( "<div>" ).dialog( { modal: true, uiDialogTitleHeadingLevel: 1 } );
+ nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
+ assert.equal( nodeName, "h1", "Element wrapping the dialog title is h1" );
+
+ element = $( "<div>" ).dialog( { modal: true, uiDialogTitleHeadingLevel: 6 } );
+ nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
+ assert.equal( nodeName, "h6", "Element wrapping the dialog title is h6" );
+
+ element = $( "<div>" ).dialog( { modal: true, uiDialogTitleHeadingLevel: 9 } );
+ nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
+ assert.equal( nodeName, "span", "Element wrapping the dialog title is span" );
+
+ element = $( "<div>" ).dialog( { modal: true, uiDialogTitleHeadingLevel: -9 } );
+ nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
+ assert.equal( nodeName, "span", "Element wrapping the dialog title is span" );
+
+ element = $( "<div>" ).dialog( { modal: true, uiDialogTitleHeadingLevel: 2.3 } );
+ nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
+ assert.equal( nodeName, "span", "Element wrapping the dialog title is span" );
+
+ element = $( "<div>" ).dialog( { modal: true, uiDialogTitleHeadingLevel: "foo" } );
+ nodeName = element.dialog( "widget" ).find( ".ui-dialog-title" ).get( 0 ).nodeName.toLowerCase();
+ assert.equal( nodeName, "span", "Element wrapping the dialog title is span" );
+} );
+
QUnit.test( "widget method", function( assert ) {
assert.expect( 1 );
var dialog = $( "<div>" ).appendTo( "#qunit-fixture" ).dialog();
diff --git a/ui/widgets/dialog.js b/ui/widgets/dialog.js
index 756ad1cb1..1ef2fa3d6 100644
--- a/ui/widgets/dialog.js
+++ b/ui/widgets/dialog.js
@@ -81,6 +81,7 @@ $.widget( "ui.dialog", {
resizable: true,
show: null,
title: null,
+ uiDialogTitleHeadingLevel: 0,
width: 300,
// Callbacks
@@ -437,7 +438,13 @@ $.widget( "ui.dialog", {
}
} );
- uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
+ var uiDialogHeadingLevel = Number.isInteger( this.options.uiDialogTitleHeadingLevel ) &&
+ this.options.uiDialogTitleHeadingLevel > 0 &&
+ this.options.uiDialogTitleHeadingLevel <= 6 ?
+ "h" + this.options.uiDialogTitleHeadingLevel : "span";
+
+ uiDialogTitle = $( "<" + uiDialogHeadingLevel + ">" )
+ .uniqueId().prependTo( this.uiDialogTitlebar );
this._addClass( uiDialogTitle, "ui-dialog-title" );
this._title( uiDialogTitle );