New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix regression in false positive caching of sass_file() #85
Conversation
Dependencies shouldn't influence Sass caching and nowadays they're always attached to the return value
…code when re-compiling
When we recently started having sass/tests/testthat/test-cache.R Lines 55 to 74 in 489f545
Turns out that test wasn't working the way I intended it to work when I added it in #63, so |
} else if (is_font_collection(x)) { | ||
x$html_deps <- NULL | ||
} else { | ||
htmlDependencies(x) <- NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this won't remove an html dependency if it's included as a child of a tag object (as opposed to being added with attachDependency()
):
x <- div(
"hello",
htmlDependency("x", "1.0", c(src = "abc"))
)
htmlDependencies(x) <- NULL
findDependencies(x)
#> [[1]]
#> List of 10
#> $ name : chr "x"
#> $ version : chr "1.0"
#> $ src :List of 1
#> ..$ src: chr "abc"
#> $ meta : NULL
#> $ script : NULL
#> $ stylesheet: NULL
#> $ head : NULL
#> $ attachment: NULL
#> $ package : NULL
#> $ all_files : logi TRUE
#> - attr(*, "class")= chr "html_dependency"
Same is true if it's an element in a tagList
or list
:
x <- tagList(
div("hello"),
htmlDependency("x", "1.0", c(src = "abc"))
)
htmlDependencies(x) <- NULL
findDependencies(x)
#> [[1]]
#> List of 10
#> $ name : chr "x"
#> $ version : chr "1.0"
#> $ src :List of 1
#> ..$ src: chr "abc"
#> $ meta : NULL
#> $ script : NULL
#> $ stylesheet: NULL
#> $ head : NULL
#> $ attachment: NULL
#> $ package : NULL
#> $ all_files : logi TRUE
#> - attr(*, "class")= chr "html_dependency"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is an actual issue since as_sass()
currently doesn't have a method for tags for dependencies (this is partially the motivation for having the sass_layer(html_deps)
):
> sass::as_sass(list(".foo{}", htmltools::htmlDependency("foo", "1.0", ".")))
Error in as_sass_.default(val) :
as_sass() not implemented for object of class: 'html_dependency'
That being said, maybe it still make sense to add a case:
} else if (inherits(x, "html_dependency")) {
x <- NULL
}
just in case we decide to add a no-op method someday
…dependencies(). This case is actually relevant given that as_sass() doesn't currently have a method for dependencies, but it's possibly that someday we'll add one https://github.com/rstudio/sass/pull/85/files\#r623952380
Closes #84