mirror of
https://github.com/rstudio/shiny.git
synced 2026-02-09 22:25:59 -05:00
make sure to remove label tag from DOM if label is updated to NULL
This commit is contained in:
@@ -4326,15 +4326,23 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
||||
receiveMessage: function receiveMessage(el, data) {
|
||||
if (data.hasOwnProperty('value')) this.setValue(el, data.value);
|
||||
|
||||
var labelTag = $(el).parent().find('label[for="' + $escape(el.id) + '"]');
|
||||
var hasLabelTag = labelTag.length > 0;
|
||||
|
||||
// If data.label exists, then we may need to insert a label
|
||||
// tag into the DOM. If it doesn't exist, then the label tag
|
||||
// should be removed to be more consistent with the behavior
|
||||
// of `textInput(label = NULL)`
|
||||
if (data.hasOwnProperty('label')) {
|
||||
var label = $(el).parent().find('label[for="' + $escape(el.id) + '"]');
|
||||
// If textInput(label=NULL), then no label tag is provided from the
|
||||
// server, so create one if we need to.
|
||||
if (label.length === 0) {
|
||||
$('<label for="' + $escape(el.id) + '">' + data.label + '</label>').insertBefore(el);
|
||||
|
||||
if (hasLabelTag) {
|
||||
labelTag.text(data.label);
|
||||
} else {
|
||||
label.text(data.label);
|
||||
$('<label for="' + $escape(el.id) + '">' + data.label + '</label>').insertBefore(el);
|
||||
}
|
||||
} else {
|
||||
|
||||
if (hasLabelTag) labelTag.remove();
|
||||
}
|
||||
|
||||
if (data.hasOwnProperty('placeholder')) el.placeholder = data.placeholder;
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
inst/www/shared/shiny.min.js
vendored
2
inst/www/shared/shiny.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user