Skip to content
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

Tag classes should be normalized on creation #205

Closed
wch opened this issue Mar 22, 2021 · 1 comment · Fixed by #212
Closed

Tag classes should be normalized on creation #205

wch opened this issue Mar 22, 2021 · 1 comment · Fixed by #212

Comments

@wch
Copy link
Collaborator

wch commented Mar 22, 2021

Tag classes are way too freeform and this makes it difficult to work with them. For example:

x <- div(class = "a", class = "b c", class = c("d", "e f"))
str(x)
#> List of 3
#>  $ name    : chr "div"
#>  $ attribs :List of 3
#>   ..$ class: chr "a"
#>   ..$ class: chr "b c"
#>   ..$ class: chr [1:2] "d" "e f"
#>  $ children: list()
#>  - attr(*, "class")= chr "shiny.tag"

It would be better if this were translated to a data structure like c("a", "b", "c", "d", "e", "f") or "a b c d e f" when the tag is created.

Edit: I've realized that class isn't special; it makes sense to do this with all HTML attributes. We'll have to be careful about types, though (attributes can be atomic vectors, but they can also be lists or tag objects).

We should also make tagAppendAttribute and friends do the same thing.

@schloerke
Copy link
Collaborator

This can not happen without major breaking changes to downstream dependencies.

Instead, tagGetAttribute(x, attr) will be updated to return a list structure of any attribs value is not an atomic value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants