Calendar: Sanitize active descendant id selector

This commit is contained in:
Felix Nagel 2014-12-28 19:59:31 +01:00 committed by Scott González
parent 43f66b8b67
commit 9d423e5b6f

View File

@ -99,9 +99,7 @@ return $.widget( "ui.calendar", {
// TODO: Handle for pickers with multiple months // TODO: Handle for pickers with multiple months
switch ( event.keyCode ) { switch ( event.keyCode ) {
case $.ui.keyCode.ENTER: case $.ui.keyCode.ENTER:
this.element.find( this.activeDescendant.mousedown();
"#" + this.grid.attr( "aria-activedescendant" ) + " > a:first"
).mousedown();
return; return;
case $.ui.keyCode.PAGE_UP: case $.ui.keyCode.PAGE_UP:
this.date.adjust( event.altKey ? "Y" : "M", -1 ); this.date.adjust( event.altKey ? "Y" : "M", -1 );
@ -147,7 +145,10 @@ return $.widget( "ui.calendar", {
.attr( "aria-activedescendant", id ) .attr( "aria-activedescendant", id )
.find( ".ui-state-focus" ) .find( ".ui-state-focus" )
.removeClass( "ui-state-focus" ); .removeClass( "ui-state-focus" );
this.grid.find( "#" + id ).find ( "a" ).addClass( "ui-state-focus" );
this.activeDescendant = this.grid.find(
this._sanitizeSelector( "#" + id ) + " > a"
).addClass( "ui-state-focus" );
}, },
_createCalendar: function() { _createCalendar: function() {
@ -470,6 +471,10 @@ return $.widget( "ui.calendar", {
return $( "<a>" ).text( this.labels[ key ] ).html(); return $( "<a>" ).text( this.labels[ key ] ).html();
}, },
_sanitizeSelector: function( hash ) {
return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
},
_setHiddenPicker: function() { _setHiddenPicker: function() {
this.element.attr({ this.element.attr({
"aria-hidden": "true", "aria-hidden": "true",