tagAppendAttributes()'s .cssSelector doesn't match top-level tag

Open
#334 11 comments 0 reactions 1 assignee View on GitHub

@schloerke is already working on this.

Since Apr 14, 2023.

Assessment

This issue has not been assessed yet.

Description

I'd expect this to add the (bar = "BAR") attribute, but it currently doesn't:

tagAppendAttributes(div(class = "foo"), .cssSelector = ".foo", bar = "BAR")
#> <div class="foo"></div>

The reason why this doesn't work is that tagQuery() is only able to $find() children of the input tag

tagQuery(div(class = "foo"))$find(".foo")
#> `$allTags()`:
#> <div class="foo"></div>

#> `$selectedTags()`: (Empty selection)

Maybe it would make sense for tagAppendAttributes() to wrap the input up into a "dummy" tag (cc @schloerke)?

Dominant language
R
Stars
225
Forks
73
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rstudio/htmltools

All issues in rstudio/htmltools

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.