Closed DavidJesse21 closed 2 years ago
tl/dr: tagQuery()
is dropping html deps when squashing tagList()
s within $children
.
Reprex:
library(htmltools)
barret_dep <- htmlDependency(name = "barret", version = 1, src = list(file = "some/file.js"))
children <- attachDependencies(list("A", "B"), barret_dep)
html <- div("example", children)
tq_html <- tagQuery(html)$allTags()
# These should match
str(html)
#> List of 3
#> $ name : chr "div"
#> $ attribs : Named list()
#> $ children:List of 2
#> ..$ : chr "example"
#> ..$ :List of 2
#> .. ..$ : chr "A"
#> .. ..$ : chr "B"
#> .. ..- attr(*, "html_dependencies")=List of 1
#> .. .. ..$ :List of 10
#> .. .. .. ..$ name : chr "barret"
#> .. .. .. ..$ version : chr "1"
#> .. .. .. ..$ src :List of 1
#> .. .. .. .. ..$ file: chr "some/file.js"
#> .. .. .. ..$ meta : NULL
#> .. .. .. ..$ script : NULL
#> .. .. .. ..$ stylesheet: NULL
#> .. .. .. ..$ head : NULL
#> .. .. .. ..$ attachment: NULL
#> .. .. .. ..$ package : NULL
#> .. .. .. ..$ all_files : logi TRUE
#> .. .. .. ..- attr(*, "class")= chr "html_dependency"
#> - attr(*, "class")= chr "shiny.tag"
str(tq_html)
#> List of 3
#> $ name : chr "div"
#> $ attribs : Named list()
#> $ children:List of 3
#> ..$ : chr "example"
#> ..$ : chr "A"
#> ..$ : chr "B"
#> - attr(*, "class")= chr "shiny.tag"
# These should match
findDependencies(html)
#> [[1]]
#> List of 10
#> $ name : chr "barret"
#> $ version : chr "1"
#> $ src :List of 1
#> ..$ file: chr "some/file.js"
#> $ meta : NULL
#> $ script : NULL
#> $ stylesheet: NULL
#> $ head : NULL
#> $ attachment: NULL
#> $ package : NULL
#> $ all_files : logi TRUE
#> - attr(*, "class")= chr "html_dependency"
findDependencies(tq_html)
#> NULL
Created on 2021-12-06 by the reprex package (v2.0.0)
Hi, I would like to use
tagQuery()
to create/modify tags like cards, navbars and panels that serve as containers for UI output. I've already posted a detailed explanation of my problem including a reprex here: https://community.rstudio.com/t/shiny-htmltools-custom-tags-behave-weird-when-using-tagquery-to-modify-tags/123308Long story short, running
tagQuery()
on a tag, that somewhere contains an htmlwidget UI output, changes the structure of the tag, such that the UI output won't be shown anymore. Weirdly, this is only the case, when you do this at least twice.I hope you can tell what the problem is and help me out.
Thanks in advance and kind regards David