namshi/dollar-dom

Name: dollar-dom

Owner: Namshi

Description: null

Created: 2017-04-11 11:48:39.0

Updated: 2018-05-17 21:02:12.0

Pushed: 2017-08-02 06:30:36.0

Homepage: null

Size: 72

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

?DOM

? A Friendly wrapper for your favourite DOM Apis ? in 800 bytes ( minified + gzipped ) ?


Build Status Open Source Namshi PRs Welcome


Why

DollarDOM is not a polyfill or a new dom library. It's a simple wrapper for these mostly used DOM APIs:

DollarDOM abstracts the above methods and provides a $ object ( jQuery style ). It also has an on method which can be chained with the $ selector function. Here is a simple example:

collection = document.querySelectorAll('.some-class');
ection = [].slice.call(collection) // required for older browsers.
ection.forEach( elem => {
em.addEventListener('click', function(){
console.log(this.innerHTML);
; 

can be written as:

.some-class').on('click', function(){ 
onsole.log(this.innerHTML);

and in a better way, with event delegation:

ocument).on('click', '.some-class', function(){ 
onsole.log(this.innerHTML);

In bullet points, you can use DollarDOM, if:

Install

using npm

npm install --save dollar-dom

using yarn

yarn add dollar-dom

If you're using module bundlers like webpack, Browserify or rollup, you can import $ from DollarDom module:

rt {$} from 'dollar-dom';

r

t {$} = require('dollar-dom');

If you wish to include as a script, DollarDOM can be included like this:

<script src="https://unpkg.com/dollar-dom/build/dollar-dom.min.js"></script>

and will be available as a global object named dollarDom in the browser.

API and Examples
$
on
get
Want to Contribute ?

We love contributions from everyone.

  1. Fork the repo.
  2. Install dependencies. yarn install or npm install
  3. We use AVA for unit tests.
    • To run unit tests, yarn test or npm test
    • To run unit test in –watch mode, yarn test-w or npm run test-w
  4. Implement the changes, and write test cases. Make sure that all unit test pass.
  5. To generate the final build, run yarn build or npm build.
  6. Push your code and create a Pull Request
Licence

MIT @ Namshi.com

Image Credits

Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.