rstudio / htmltools

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

save_html() errors out with non-src script attributes #288

Closed cpsievert closed 2 years ago

cpsievert commented 3 years ago
dep <- htmlDependency(
  name = "a",
  version = "1.0",
  package = "shiny",
  src = "www/shared",
  script = list(src = "jquery.min.js", defer = NA),
  all_files = FALSE
)
save_html(div(dep), "index.html")
#> Error in copyDependencyToDir(dep, libdir, FALSE) : 
#>  Can't copy dependency files that don't exist: '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/shiny/www/shared/jquery.min.js', '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/shiny/www/shared/NA'

It's because this line in copyDependencyToDit() is assuming the script field is a character vector

https://github.com/rstudio/htmltools/blob/bc226a3d728c84c53c69fe5d48140fc664fe3dc8/R/html_dependency.R#L357

cpsievert commented 2 years ago

Addressed by https://github.com/rstudio/htmltools/commit/5fe6cd67b25153302351fd026a070d1a7660d7a6