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
tagGetAttribute(x, attr)
returns a list if one of the values is not atomic
#212
Conversation
Co-authored-by: Winston Chang <winston@stdout.org>
Following up a discussion we had: We decided that we would always collapse multiple entries with the same name into a single vector/list, allowing type promotion to happen normally. For example, If the input includes a list or other complex data structure, like Note that we also need to be a bit careful about factors. An additional thought I had afterward: we could add a parameter named z <- div(x = "a b", x = "c")
tagGetAttribute(z, "x")
#> [1] "a b c"
tagGetAttribute(z, "x", split = TRUE)
#> [1] "a" "b" "c" This would make it more convenient to check if the attribute contains a specific value, like I'm not sure the best way to handle attributes which are lists here, though. |
* master: Set min `rlang` version to 0.4.10.9000
….; Undo all other changes to make this possible
After more discussion, users are already abusing With the latest implementation, characters are returned as normal. z <- div(a = "x", a = "y")
z
#> <div a="x y"></div>
tagGetAttribute(z, "a")
#> [1] "x y" But non atomic values are returned using a list structure, avoiding a call to w <- div(a = "x", a = list(obj = TRUE))
tagGetAttribute(w, "a")
#> [[1]]
#> [1] "x"
#>
#> [[2]]
#> [[2]]$obj
#> [1] TRUE
w
#> <div a="x TRUE"></div> |
* master: Rename `rlang::sexp_address()` to `rlang::obj_address()` (#220)
tagGetAttribute(x, attr)
returns a list if one of the values is not atomic
I think this PR is ready to be merged. The comment above shows a typical use case and a not-recommended use case. The internal |
* master: `tagQuery()`: Rename`$root()` to `$allTags()`, `$selected()` to `$selectedTags()`; Print `$selectedTags()` like a `list()` (#230) tagQuery(): Rebuild less often and do not check for tag env cycles; Rename `$reset()` -> `$resetSelected()` (#235) Bump rlang dev version Revert "Return invisibly when not creating a new tagQuery() object (#228)" Allow tag query `$*Class()` methods to no-op on length 0 inputs (#236)
Similar behavior to printing the tag attribute
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.
LGTM pending minor suggestions
…mltools into normalize_tag_attribs
Could not approach by flattening and splitting values. Too many downstream dependencies reach into the
attribs
.Fixes #205
To get around more complicated attribs values, a list will be returned if any value is not atomic. We still recommend that everyone use character values only (or values that can be pasted together).