Coder Social home page Coder Social logo

compactjs / uea Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 2.35 MB

Allow a range of different ways to select HTML Elements in your function

Home Page: https://compactjs.github.io/uea/

License: MIT License

JavaScript 2.07% HTML 46.41% TypeScript 51.52%
javascript html element input array html-elements uea

uea's Introduction

@compactjs/uea

Universal Element Accept

Allows a range of different ways to select HTML Elements

Version License: MIT

· Homepage · View Demo · Report Bug / Request Feature ·

You are writing a JavaScript library and need to receive one or more HTML elements? But you want to leave your users a broad choice, on how to select them? Then this might be for you.

Table of Contents

What this is

Universal Element Accept (uea) allows you to accept a range of different inputs as HTML elements.

It accepts query selector strings, arrays, NodeLists and more (check out usage) and always returns either an array with HTMLElements or a single element, depending on the function you use.

Install

NPM:

npm install @compactjs/uea

CDN:

<script src="https://unpkg.com/@compactjs/uea/dist/index.umd.js"></script>

Usage

As module:

import { select, selectOne } from '@compactjs/uea';

Example:

// select multiple elements
select('.my-classes');
select(document.getElementById('my-id'));
select(document.forms);

// or only select a single element
selectOne('.my-classes');
selectOne(document.getElementById('my-id'));

Check out the demo and the examples file for more examples.

Doc:

/**
 * Use a range of different ways to select HTML elements.
 * Always returns an array of elements.
 */
export function select(
  input: string | HTMLElement | HTMLElement[] | HTMLCollection | NodeList
): HTMLElement[];

/**
 * Use a range of different ways to select an HTMLElement.
 * Always returns a single HTMLElement.
 */
export function selectOne(selector: string | HTMLElement): HTMLElement | null;

Run tests

npm run test

Contact

👤 Timo Bechtel

🤝 Contributing

Contributions, issues and feature requests are welcome!

  1. Check issues
  2. Fork the Project
  3. Create your Feature Branch (git checkout -b feat/AmazingFeature)
  4. Test your changes npm run test
  5. Commit your Changes (git commit -m 'feat: add amazingFeature')
  6. Push to the Branch (git push origin feat/AmazingFeature)
  7. Open a Pull Request

Commit messages

This project uses semantic-release for automated release versions. So commits in this project follow the Conventional Commits guidelines. I recommend using commitizen for automated commit messages.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Distributed under the MIT License.


This README was generated with ❤️ by readme-md-generator

uea's People

Contributors

dependabot[bot] avatar semantic-release-bot avatar timobechtel avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.