1.0.10 • Published 5 years ago

generate-get-element-by-data-attribute v1.0.10

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

Generate Get Element by Data Attribute

npm version Build Status

This package aims to prevent you from having to write same function over and over again.

Instead of writing

document.querySelector("[data-testid=my-first-button");
document.querySelector("[data-testid=my-second-button");
document.querySelector("[data-testid=my-third-button");

each time you would like to access an element from a testid, this package allow you to write

import { generateGetElementByDataAttribute } from "generate-get-element-by-data-attribute";

const getElementByTestId = generateGetElementByDataAttribute("testid");

getElementByTestId(document.body, "first-button");
getElementByTestId(document.body, "second-button");
getElementByTestId(document.body, "third-button");

Helpful for writing a lot of Jest tests.

Type definitons are provided!

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago