Coder Social home page Coder Social logo

ess.js's Introduction

ess.js

A fast, simple, opinionated selector "engine".

Build Status

This module provides a simple way to query the DOM for elements by ID, class or tag name only. It was designed to be both small and to force users to make efficient DOM queries. This is useful when developing for mobile devices and to prevent JavaScript being coupled too heavily to the DOM hierarchy. It intentionally does not and will never support more complicated ways of querying on the basis that these are slow and can be avoided through the use of extra classes (also, there are many other projects around which fulfil this job very well already). This module is AMD compatible.

Examples

// Queries by ID, class or tag name
ess('#nav'); // returns DOMNode
ess('.current'); //returns DOMNode array
ess('li'); //returns DOMNode array

// Space-separated, drill-down queries
ess('#nav .current'); // returns DOMNode array
ess('#nav li'); // returns DOMNode array

// Specifying a DOM context to perform the query
var navElement = ess('#nav');
ess('li', navElement); // returns DOMNode array

Queries that it cannot do

  • Qualified selectors: li.current (maybe soon)
  • Non-simplistic selectors: div > ul or p + p
  • Comma-separated selectors: input, select, textarea
  • Anything else other than atomistic, space-separated selection by ID, class and tag!

Other caveats

  • Searching for an element by ID will ignore any given context, e.g. body #nav is equivalent to #nav

Ess-Bonzo-Bean

Ess is well complemented by the Bonzo and Bean modules, which together provide a decent jQuery-like DOM manipulation set up. This project includes an integration of the three modules. When using the integrated version of Ess, your queries will return Bonzo objects with chainable Bean methods available on top, and a find() method to drill-down a DOM query. You can also pass an element and get a Bonzo wrapped object back.

Compatibility

Chrome, Firefox, IE8+, Safari, Android

Contributing

Contributions are welcome, though the core module has a very limited scope and I do not intend for it to become too large. To make a change, edit the files in the src directory. You can then run build, tests and benchmark using the Makefile. Please commit built files with your changes.

Credits

Thanks to...

ess.js's People

Contributors

cmbuckley avatar jamesbarwell avatar teddyzetterlund 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.