mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Datepicker: Make sure altField is treated as a CSS selector
Closes gh-1954
This commit is contained in:
parent
9380d2734e
commit
32850869d3
@ -623,8 +623,10 @@ QUnit.test( "setDate", function( assert ) {
|
||||
} );
|
||||
|
||||
QUnit.test( "altField", function( assert ) {
|
||||
assert.expect( 10 );
|
||||
var inp = testHelper.init( "#inp" ),
|
||||
assert.expect( 11 );
|
||||
|
||||
var done = assert.async(),
|
||||
inp = testHelper.init( "#inp" ),
|
||||
alt = $( "#alt" );
|
||||
|
||||
// No alternate field set
|
||||
@ -664,6 +666,22 @@ QUnit.test( "altField", function( assert ) {
|
||||
inp.simulate( "keydown", { ctrlKey: true, keyCode: $.ui.keyCode.END } );
|
||||
assert.equal( inp.val(), "", "Alt field - dp - ctrl+end" );
|
||||
assert.equal( alt.val(), "", "Alt field - alt - ctrl+end" );
|
||||
|
||||
// HTML instead of selector
|
||||
alt.val( "" );
|
||||
try {
|
||||
inp.datepicker( "option", {
|
||||
altField: "<img onerror='window.globalAltField=true' src='/404' />",
|
||||
altFormat: "yy-mm-dd"
|
||||
} ).val( "06/04/2008" ).datepicker( "show" );
|
||||
inp.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
|
||||
} catch ( e ) {}
|
||||
|
||||
setTimeout( function() {
|
||||
assert.equal( window.globalAltField, undefined, "altField treated as a selector" );
|
||||
delete window.globalAltField;
|
||||
done();
|
||||
}, 500 );
|
||||
} );
|
||||
|
||||
QUnit.test( "autoSize", function( assert ) {
|
||||
|
@ -1089,7 +1089,7 @@ $.extend( Datepicker.prototype, {
|
||||
altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" );
|
||||
date = this._getDate( inst );
|
||||
dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) );
|
||||
$( altField ).val( dateStr );
|
||||
$( document ).find( altField ).val( dateStr );
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user