Skip to content

Commit 8d5a998

Browse files
authored
Make sure NA attributes are rendered as blank for script (#201)
* Make sure NA attributes are rendered as blank for script * test if defer = NA becomes defer attribute * fix Error: Calling `brew cask install` is disabled! Use brew install [--cask] instead.
1 parent e7f0393 commit 8d5a998

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
- name: Mac systemdeps
6969
if: runner.os == 'macOS'
7070
run: |
71-
brew cask install xquartz
71+
brew install --cask xquartz
7272
brew install cairo
7373
7474
- name: Install dependencies

R/html_dependency.R

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -556,13 +556,11 @@ renderScript <- function(script, srcpath, encodeFunc, hrefFilter) {
556556
script, function(x) {
557557
x$src <- hrefFilter(file.path(srcpath, encodeFunc(x$src)))
558558
paste0(
559-
"<script",
559+
"<script",
560560
paste0(
561-
" ",
561+
" ",
562562
htmlEscape(names(x)),
563-
'="',
564-
htmlEscape(x),
565-
'"',
563+
ifelse(is.na(x), "", paste0('="', htmlEscape(x), '"')),
566564
collapse = ''
567565
),
568566
"></script>",

tests/testthat/test-deps.r

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ test_that("able to resolve HTML scripts supplied with & without integrity", {
199199
script = list(
200200
src = "p1.min.js",
201201
integrity = "longhash",
202-
crossorigin = "anonymous"
202+
crossorigin = "anonymous",
203+
defer = NA
203204
)
204205
),
205206
htmlDependency(
@@ -212,7 +213,7 @@ test_that("able to resolve HTML scripts supplied with & without integrity", {
212213
expect1 <- paste(
213214
'<script src="', src1, 'p1.min.js','" ',
214215
'integrity="longhash" ',
215-
'crossorigin="anonymous"></script>',
216+
'crossorigin="anonymous" defer></script>',
216217
sep = ''
217218
)
218219
expect2 <- paste(

0 commit comments

Comments
 (0)