Explorar el Código

list2css() handles duplicated selectors and property names

tags/v0.3.0
Garrick Aden-Buie hace 6 años
padre
commit
8025d1ea61
Se han modificado 2 ficheros con 17 adiciones y 4 borrados
  1. +5
    -4
      R/style_extra_css.R
  2. +12
    -0
      tests/testthat/test-style_extra_css.R

+ 5
- 4
R/style_extra_css.R Ver fichero

stop(msg, call. = FALSE) stop(msg, call. = FALSE)
} }


purrr::map_chr(names(css), function(el) {
x <- purrr::imap_chr(css, function(rules, selector) {
paste( paste(
sep = "\n", sep = "\n",
el %.% " {",
selector %.% " {",
paste( paste(
purrr::map_chr(names(css[[el]]), function(prop) {
" " %.% prop %.% ": " %.% css[[el]][[prop]] %.% ";"
purrr::imap_chr(rules, function(value, prop) {
" " %.% prop %.% ": " %.% value %.% ";"
}), }),
collapse = "\n" collapse = "\n"
), ),
"}" "}"
) )
}) })
unname(x)
} }


list2fonts <- function(fonts) { list2fonts <- function(fonts) {

+ 12
- 0
tests/testthat/test-style_extra_css.R Ver fichero

"elements.+must be named.+body, thing.+have" "elements.+must be named.+body, thing.+have"
) )
}) })

it("is okay for multiple entries with the same name", {
expect_equal(
list2css(list("a" = list(color = "red"), a = list(color = "blue"))),
c("a {\n color: red;\n}", "a {\n color: blue;\n}")
)

expect_equal(
list2css(list("a" = list(color = "red", color = "blue"))),
c("a {\n color: red;\n color: blue;\n}")
)
})
}) })





Cargando…
Cancelar
Guardar