Datepicker: Escape single quotes in tooltips. Fixes #9049 - Datepicker beforeShowDay tooltip not displayed properly if single quote is used.

This commit is contained in:
Scott González 2013-02-01 16:52:04 -05:00
parent dddf2a7ca1
commit df179542cc
2 changed files with 16 additions and 1 deletions

View File

@ -782,6 +782,21 @@ test("callbacks", function() {
inp.datepicker("hide").datepicker("destroy"); inp.datepicker("hide").datepicker("destroy");
}); });
test("beforeShowDay - tooltips with quotes", function() {
expect( 1 );
var inp, dp;
inp = TestHelpers.datepicker.init("#inp", {
beforeShowDay: function() {
return [ true, "", "'" ];
}
});
dp = $("#ui-datepicker-div");
inp.datepicker("show");
equal( dp.find( ".ui-datepicker-calendar td:contains('9')").attr( "title" ), "'" );
inp.datepicker("hide").datepicker("destroy");
});
test("localisation", function() { test("localisation", function() {
expect( 24 ); expect( 24 );
var dp, month, day, date, var dp, month, day, date,

View File

@ -1741,7 +1741,7 @@ $.extend(Datepicker.prototype, {
(otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
(printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
(printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different) (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2] + "'" : "") + // cell title ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "'") + "'" : "") + // cell title
(unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
(otherMonth && !showOtherMonths ? " " : // display for other months (otherMonth && !showOtherMonths ? " " : // display for other months
(unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" + (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +