]> source.dussan.org Git - jquery-ui.git/commitdiff
Datepicker: Escape single quotes in tooltips. Fixes #9049 - Datepicker beforeShowDay...
authorScott González <scott.gonzalez@gmail.com>
Fri, 1 Feb 2013 21:52:04 +0000 (16:52 -0500)
committerScott González <scott.gonzalez@gmail.com>
Fri, 1 Feb 2013 21:52:04 +0000 (16:52 -0500)
tests/unit/datepicker/datepicker_options.js
ui/jquery.ui.datepicker.js

index dac2262dcc4b0600a62c0c996186eedd9f69f846..1efd854a9493e18f121c6738ba5ca245530f71d6 100644 (file)
@@ -782,6 +782,21 @@ test("callbacks", function() {
        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() {
        expect( 24 );
        var dp, month, day, date,
index e93f596fc5595eff31bf2d7820827531a4b05d54..b893f582d280d58110e83361189b353a54cd1b24 100644 (file)
@@ -1741,7 +1741,7 @@ $.extend(Datepicker.prototype, {
                                                        (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
                                                        (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
                                                        (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, "&apos;") + "'" : "") + // cell title
                                                        (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
                                                        (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
                                                        (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +