Allow DOM element replacement in htmlOutput #694
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a
replace
option tohtmlOutput()
. When set to TRUE, it tells Shiny that the output fromrenderUI
should replace the container DOM element, instead of being placed inside of the container. This is useful in cases where an intervening<div>
or<span>
element isn't allowed, or will interfere with CSS selectors.When replacement happens, the new element gets the old element's ID, and also gets assigned the classes
"shiny-html-output shiny-html-replace-output"
. IfrenderUI
returns something other than a single tag (like atagList
or bare text), it's not possible to replace the container element with the new content, preserving ID and and keeping those classes; in this case, the content will be placed inside the container element, as thoughreplace=FALSE
.This example doesn't show the proper styling for the
li
(red text), because of the extradiv
in the DOM structure:With
replace=TRUE
, theli
comes up with the correct styling:This addresses rstudio/shinydashboard#1.