rstudio / htmltools

Tools for HTML generation and output
https://rstudio.github.io/htmltools/
214 stars 67 forks source link

tagAppendAttributes() et al doesn't work with non-tagified objects #374

Open cpsievert opened 1 year ago

cpsievert commented 1 year ago

Functions that are intended to modify tags, like tagAppendAttributes(), bindFillRole(), etc. should probably be tagify()-ing their input, or else you get weird behavior:

> str(tagAppendAttributes(leaflet::leaflet(), foo = "bar"))
List of 9
 $ x            :List of 1
  ..$ options:List of 1
  .. ..$ crs:List of 5
  .. .. ..$ crsClass       : chr "L.CRS.EPSG3857"
  .. .. ..$ code           : NULL
  .. .. ..$ proj4def       : NULL
  .. .. ..$ projectedBounds: NULL
  .. .. ..$ options        : Named list()
  .. .. ..- attr(*, "class")= chr "leaflet_crs"

[...]

 $ attribs      :List of 1
  ..$ foo: chr "bar"
 - attr(*, "class")= chr [1:2] "leaflet" "htmlwidget"
 - attr(*, "package")= chr "leaflet"