Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/justeat/f-dom

Fozzie JS DOM queries library.
https://github.com/justeat/f-dom

fozzie ui

Last synced: about 1 month ago
JSON representation

Fozzie JS DOM queries library.

Awesome Lists containing this project

README

        


f-dom

Fozzie Bear

Fozzie JS DOM queries library, built on top of the qwery selector engine.


---

[![npm version](https://badge.fury.io/js/%40justeat%2Ff-dom.svg)](https://badge.fury.io/js/%40justeat%2Ff-dom)
[![Build Status](https://travis-ci.org/justeat/f-dom.svg)](https://travis-ci.org/justeat/f-dom)
[![Coverage Status](https://coveralls.io/repos/github/justeat/f-dom/badge.svg)](https://coveralls.io/github/justeat/f-dom)
[![Known Vulnerabilities](https://snyk.io/test/github/justeat/f-dom/badge.svg?targetFile=package.json)](https://snyk.io/test/github/justeat/f-dom?targetFile=package.json)

## Adding `f-dom` to your project

```bash
yarn add @justeat/f-dom
```

Then, inside your script import `f-dom`.

```js
import $ from '@justeat/f-dom';
```

## Usage

Each method has 2 parameters: mandatory `selector` and optional `root`.
If `root` parameter is not specified, search will be performed for all elements in the DOM, otherwise, search will be performed for `root` child elements.

`first` method returns first element in the DOM for the specified selector.

```js
const element = $.first('.btn');
...
const element = $.first('#btn', '.container');
```

`all` method returns all elements in the DOM for the specified selector.

```js
const element = $.all('.btn');
...
const element = $.all('.btn', '.container');
...
const element = $('.btn'); // short syntax
```

`exists` method returns true, if at least one element exists in the DOM, otherwise returns false.

```js
const exists = $.exists('.btn');
...
const exists = $.exists('.btn', '.container');
```