mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Controlgroup: Fix create and destroy for controlgroupLabel
Creating the label broke while doing a refactoring, the lack of tests allowed that to go unnoticed. Shouldn't happen again with the extra tests, covering both controlgroupLabel and spinner.
This commit is contained in:
parent
bb56dd59e8
commit
09fde89a24
@ -5,7 +5,7 @@
|
|||||||
<title>jQuery UI Controlgroup Test Suite</title>
|
<title>jQuery UI Controlgroup Test Suite</title>
|
||||||
|
|
||||||
<script src="../../../external/requirejs/require.js"></script>
|
<script src="../../../external/requirejs/require.js"></script>
|
||||||
<script src="../../lib/css.js" data-modules="core button checkboxradio selectmenu controlgroup"></script>
|
<script src="../../lib/css.js" data-modules="core button checkboxradio selectmenu spinner controlgroup"></script>
|
||||||
<script src="../../lib/bootstrap.js" data-modules="common core methods options"></script>
|
<script src="../../lib/bootstrap.js" data-modules="common core methods options"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -28,6 +28,8 @@
|
|||||||
</select>
|
</select>
|
||||||
<div class="test"></div>
|
<div class="test"></div>
|
||||||
<button>Button with icon on the bottom</button>
|
<button>Button with icon on the bottom</button>
|
||||||
|
<label for="spinner" class="ui-controlgroup-label"># of cars</label>
|
||||||
|
<input id="spinner" class="ui-spinner-input">
|
||||||
<select>
|
<select>
|
||||||
<option>Fast</option>
|
<option>Fast</option>
|
||||||
<option>Medium</option>
|
<option>Medium</option>
|
||||||
|
@ -9,13 +9,11 @@ define( [
|
|||||||
module( "Controlgroup: Core" );
|
module( "Controlgroup: Core" );
|
||||||
|
|
||||||
test( "selectmenu: open/close corners", function( assert ) {
|
test( "selectmenu: open/close corners", function( assert ) {
|
||||||
expect( 1 );
|
expect( 12 );
|
||||||
var element = $( ".controlgroup" ).controlgroup(),
|
var element = $( ".controlgroup" ).controlgroup(),
|
||||||
selects = element.find( "select" ),
|
selects = element.find( "select" ),
|
||||||
selectButton = selects.eq( 0 ).selectmenu( "widget" );
|
selectButton = selects.eq( 0 ).selectmenu( "widget" );
|
||||||
|
|
||||||
expect( 12 );
|
|
||||||
|
|
||||||
selects.eq( 0 ).selectmenu( "open" );
|
selects.eq( 0 ).selectmenu( "open" );
|
||||||
assert.hasClasses( selectButton, "ui-corner-tl",
|
assert.hasClasses( selectButton, "ui-corner-tl",
|
||||||
"Horizontal: First selectmenu gets ui-corner-tl when opened" );
|
"Horizontal: First selectmenu gets ui-corner-tl when opened" );
|
||||||
@ -66,4 +64,13 @@ test( "selectmenu: open/close corners", function( assert ) {
|
|||||||
"vertical: Last selectmenu gets ui-corner-bottom when closed" );
|
"vertical: Last selectmenu gets ui-corner-bottom when closed" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
test( "selectmenu: controlgroupLabel", function( assert ) {
|
||||||
|
expect( 2 );
|
||||||
|
var element = $( ".controlgroup" ).controlgroup();
|
||||||
|
var label = element.find( ".ui-controlgroup-label" );
|
||||||
|
|
||||||
|
assert.hasClasses( label, "ui-widget ui-widget-content ui-state-default ui-controlgroup-item" );
|
||||||
|
assert.hasClasses( label.find( "span" ), "ui-controlgroup-label-contents" );
|
||||||
|
} );
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
@ -61,6 +61,12 @@ return $.widget( "ui.controlgroup", {
|
|||||||
this._callChildMethod( "destroy" );
|
this._callChildMethod( "destroy" );
|
||||||
this.childWidgets.removeData( "ui-controlgroup-data" );
|
this.childWidgets.removeData( "ui-controlgroup-data" );
|
||||||
this.element.removeAttr( "role" );
|
this.element.removeAttr( "role" );
|
||||||
|
if ( this.options.items.controlgroupLabel ) {
|
||||||
|
this.element
|
||||||
|
.find( this.options.items.controlgroupLabel )
|
||||||
|
.find( ".ui-controlgroup-label-contents" )
|
||||||
|
.contents().unwrap();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_initWidgets: function() {
|
_initWidgets: function() {
|
||||||
@ -72,8 +78,8 @@ return $.widget( "ui.controlgroup", {
|
|||||||
var labels;
|
var labels;
|
||||||
var options = {};
|
var options = {};
|
||||||
|
|
||||||
// Make sure the widget actually exists and has a selector set
|
// Make sure the widget has a selector set
|
||||||
if ( !$.fn[ widget ] || !selector ) {
|
if ( !selector ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +93,11 @@ return $.widget( "ui.controlgroup", {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure the widget actually exists
|
||||||
|
if ( !$.fn[ widget ] ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// We assume everything is in the middle to start because we can't determine
|
// We assume everything is in the middle to start because we can't determine
|
||||||
// first / last elements until all enhancments are done.
|
// first / last elements until all enhancments are done.
|
||||||
if ( that[ "_" + widget + "Options" ] ) {
|
if ( that[ "_" + widget + "Options" ] ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user