jquery/jquery-ui

Datepicker buttonText renders as text, not html

Closed this issue · 2 comments

It looks like at some point between 1.12 and 1.13, the datepicker's buttonText started getting added as text, not HTML. For example, if I create a datepicker as:

$("#myelement").datepicker({"showOn": "button", "buttonText": "Click <b>here</b>"})

I get a trigger button that contains the text "here" instead of bolding the text.

I think the change is, when the buttonText is added to the widget, it is using jQuery's text() function, instead of the html() function.

mgol commented

Thanks for the report.

Yes, this was done in #1953. The docs have always described this property as setting text on the element, not HTML, the implementation was incorrect - someone expecting text to be applied and getting it treated as HTML could lead to security issues, so we changed that in 1.13.0.

If all you need is bold, I'd recommend just styling it via CSS.

mgol commented

Closing for now.