cferdinandi / cferdinandi/tabby

Allow passing a node instead of a selector

Open
#134 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
612
Forks
75
PR merge metrics
No merged PRs in 30d

Description

I've come across some situations where I don't know how many sets of tab will be on a page, and so have to loop over all instances of `[data-tabs]` to initialize a Tabby for it. I've achieved this with..

```
const ELEMENTS = document.querySelectorAll("[data-tabs]");

if (ELEMENTS.length > 0) {
ELEMENTS.forEach((element) => {
new Tabby(`#${element.getAttribute("id")}`);
});
}
```

but that seems somewhat fragile and also confusing to read. Being able to directly pass `element` in this case would really simplify things.

Contributor guide

Open the contributing guide

Research direction

Start at the Tabby constructor used in the issue's `new Tabby(...)` example and trace how its argument is initialized. Support passing the element directly while preserving selector usage, then verify that both forms initialize tabs correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.