Skip to content

Commit

Permalink
remove unnecessary dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
daattali committed Nov 12, 2017
1 parent 27cefb7 commit e51b648
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
8 changes: 3 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: shinyjs
Title: Easily Improve the User Experience of Your Shiny Apps in Seconds
Version: 0.9.0.9002
Version: 0.9.0.9003
Authors@R: person("Dean", "Attali", email = "daattali@gmail.com",
role = c("aut", "cre"))
Description: Perform common useful JavaScript operations in Shiny apps that will
Expand All @@ -15,14 +15,12 @@ Depends:
R (>= 3.1.0)
Imports:
digest (>= 0.6.8),
htmltools (>= 0.2.6),
htmltools (>= 0.2.9),
jsonlite,
shiny (>= 0.11.1),
stats
shiny (>= 0.11.1)
Suggests:
knitr (>= 1.7),
rmarkdown,
rstudioapi (>= 0.5),
shinyAce,
testthat (>= 0.9.1),
V8 (>= 0.6)
Expand Down
2 changes: 1 addition & 1 deletion R/delay.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ delay <- function(ms, expr) {
hashable <- sprintf("%s_%s_%s_%s",
ms,
as.integer(Sys.time()),
as.integer(stats::runif(1, 0, 1e9)),
as.integer(sample(1e9, 1)),
deparse(substitute(expr)))
hash <- digest::digest(hashable, algo = "md5")

Expand Down
4 changes: 3 additions & 1 deletion R/onevent.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ oneventHelper <- function(event, id, expr, add) {
# given expression. To support multiple event handlers, each time this
# is called, a random number is attached to the Shiny input id
shinyInputId <- sprintf("shinyjs-%s-%s-input-%s",
id, as.integer(stats::runif(1, 0, 1e9)), event)
id,
as.integer(sample(1e9, 1)),
event)
shinyInputIdJs <- shinyInputId
if (inherits(session, "session_proxy")) {
shinyInputIdJs <- session$ns(shinyInputIdJs)
Expand Down
24 changes: 7 additions & 17 deletions tests/testthat/test-hidden.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
context("hidden")

getClasses <- function(tag) {
unlist(strsplit(tag$attribs$class, " "))
unlist(strsplit(htmltools::tagGetAttribute(tag, "class"), " "))
}

clsName <- "shinyjs-hide"
Expand All @@ -11,28 +11,18 @@ test_that("hidden fails on plain text", {
})

test_that("hidden works on simple div", {
tag <- hidden(shiny::div("abc"))$attribs$class
classes <- unlist(strsplit(tag, " "))
expect_true(clsName %in% classes)
tag <- hidden(shiny::div("abc"))
expect_true(clsName %in% getClasses(tag))
})

test_that("hidden works on complex div", {
tag <- hidden(shiny::div(shiny::span("abc")))$attribs$class
classes <- unlist(strsplit(tag, " "))
expect_true(clsName %in% classes)
tag <- hidden(shiny::div(shiny::span("abc")))
expect_true(clsName %in% getClasses(tag))
})

test_that("hidden works when div already contains a class", {
expect_true(TRUE)
# TODO if a tag has more than one class, $attribs stores each class as its
# own element in the list. This means the list has multiple elements with the
# same name. This feels wrong - $atrrbis$class should either return a vector
# of classes or a string containing all the classes with a space separation.
# Until that's fixed, I'm not checking for multiple classes because
# $attribs$class only returns the first class
# I sent a pull request to htmltools to fix this, still waiting for them
# to incorporate my code
#expect_true(clsName %in% hidden(div("abc", class = "test"))$attribs$class)
tag <- hidden(shiny::div("abc", class = "test"))
expect_true(clsName %in% getClasses(tag))
})

test_that("hidden errors when one of multiple tags is not a tag", {
Expand Down

0 comments on commit e51b648

Please sign in to comment.