From afe20b79a64266e64011f34b26a30b3d1c62fd47 Mon Sep 17 00:00:00 2001 From: Michał Gołębiowski-Owczarek Date: Wed, 12 May 2021 00:59:42 +0200 Subject: Datepicker: Make sure text option are text, shorten HTML strings Instead of using enormous HTML strings, various elements are now constructed using jQuery APIs. This makes it more obvious user-provided data is used correctly. Fixes #15284 Closes gh-1953 --- ui/widgets/datepicker.js | 136 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 115 insertions(+), 21 deletions(-) (limited to 'ui/widgets') diff --git a/ui/widgets/datepicker.js b/ui/widgets/datepicker.js index f03e075cd..4fd8843cf 100644 --- a/ui/widgets/datepicker.js +++ b/ui/widgets/datepicker.js @@ -240,7 +240,9 @@ $.extend( Datepicker.prototype, { inst.append.remove(); } if ( appendText ) { - inst.append = $( "" + appendText + "" ); + inst.append = $( "" ) + .addClass( this._appendClass ) + .text( appendText ); input[ isRTL ? "before" : "after" ]( inst.append ); } @@ -257,12 +259,32 @@ $.extend( Datepicker.prototype, { if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked buttonText = this._get( inst, "buttonText" ); buttonImage = this._get( inst, "buttonImage" ); - inst.trigger = $( this._get( inst, "buttonImageOnly" ) ? - $( "" ).addClass( this._triggerClass ). - attr( { src: buttonImage, alt: buttonText, title: buttonText } ) : - $( "" ).addClass( this._triggerClass ). - html( !buttonImage ? buttonText : $( "" ).attr( - { src:buttonImage, alt:buttonText, title:buttonText } ) ) ); + + if ( this._get( inst, "buttonImageOnly" ) ) { + inst.trigger = $( "" ) + .addClass( this._triggerClass ) + .attr( { + src: buttonImage, + alt: buttonText, + title: buttonText + } ); + } else { + inst.trigger = $( "" : "" ); - - buttonPanel = ( showButtonPanel ) ? "
" + ( isRTL ? controls : "" ) + - ( this._isInRange( inst, gotoDate ) ? "" : "" ) + ( isRTL ? "" : controls ) + "
" : ""; + controls = ""; + if ( !inst.inline ) { + controls = $( "