microbe is a javascript library to aid in DOM manipulation as well as facilitating events, object observation, and data binding. It uses the micro character ( µ ) that is accessible in:
- osx: alt-m
- windows: alt+0181
- linux: alt gr+m or alt+230
microbe aims to be modular and expandable. It’s separated into several modules:
-
Selector engine with CSS4 selector support and base functions (find, filter, siblings, children, … )
-
Core helpers (class, extend, text, attributes … )
-
DOM helpers (append, appendTo, insertAfter, prepend … )
-
Type helpers(isUnidentified, isArray, isWindow, … )
-
HTTP helpers making use of Promises (get, post, … )
-
Object.observe watches objects for changes. It can also watch itself for changes in element get/set data
-
Events - binding and emitting custom events
-
See the full list in the docs
microbes are always array-like for consistency and can be extended and merged very easily.
Don’t hesitate to file issues and features requests! Or change things yourself and send a pull request.
-
npm i --S microbejs
or
-
bower install -S microbejs
or
-
<script src="./microbe.js"></script>
// all divs on the page
var µDivs = µ( 'div' ) ;
// create a div with the class example--class
var newDiv = µ( '<div.example--class>' );
// all divs get a newDiv or a clone of newDiv inserted into the DOM after them
µDivs.insertAfter( newDiv );
// watches the class of each div
µDivs.observe( 'class', function( e )
{
console.log( 'your class changed' );
} );
// gives the class example--class to each div also triggers the observe fuctions
µDivs.addClass( 'example--class' );
// sets a custom event watch
µDivs.on( 'toTheMoon', function( e )
{
console.log( e.detail );
} );
// emits a custom event to all elements in µDivs with a custom data packet.
// triggers the event listener to show the sent data
µDivs.emit( 'toTheMoon', { moon : 'close' } );
- Clone repo
- Make sure node and npm is installed
npm install
npm start
- microbe.js
npm run gulp
ornpm run microbe
- microbe.selectorEngine.js
npm run selectorEngine
- microbe.toolkit.js
npm run toolkit
npm run docs
(this command will watch for changes)
We gladly accept and review any pull-requests. Feel free! ❤️
Otherwise, if you just want to talk, we are very easy to get a hold of!
- Slack: microbejs.slack.com
- Twitter: @microbejs
- Email: [email protected]
- Web: http://m.icro.be
- Git: https://github.com/sociomantic/microbe/
- IRC (freenode): #microbe
This project adheres to the Contributor Covenant. By participating, you are expected to honor this code.
Need to report something? [email protected]
- added travi-ci testing
- added nightmare command line testing
- removed gitter
- added appendTo and prependTo
- aliased each to forEach for array compatability
- added slack community to readme and www
- children, childrenFlat, siblings, siblingsFlat now all accept filter strings
- changes to siblings, siblingsFlat, filter, and find using + and ~
- selectorEngine now accepts functions as "document ready" short hand
- added bower support
- µ.ready now accepts an arguments array
- added examples to docs
- updated code of conduct
- toggleClass now accepts an array of classes
- twitter account added to info
- updated copy and tests
- updated readme with how to use the µ symbol
- copy and logo changes on ./www
- regenerated doc
- updated gulpfile
- moved functions and structure to enable modular building
- updated remove
- core and dom now check before they use something from a different module
- updated readme, gulpfile, tests, docs, and comments
- selectorEngine utils split into core and root
- cytoplasm now accepts html strings for element creation (single or multiple elements)
- selector strings of multiple classes are now 10x faster
- code cleaned of unused variables
- many push replaces with null -> filter
- iteration abstracted
- changed internal structure to allow for closed array.prototype use
- added contact info to readme
- upgraded tests
- fixed bugs with setting falsey values into text/html
- fixed bugs with selection by id
- updated copy on site and readme
- added code of conduct and contact email
- cross browser compatability fixes
- namespace bug fixed in Observe Utils shim
- selector engine abstracted
- modular building now supported
- fixed a bug in find that left illegal whitespace
- speed fixes
- automated version scaling in static pages
- append and prepend now accept html
- prepend tweaks and docs
- custom nth selectors now support 'even' and 'odd' keywords
- .root() removed; :root simplified
- many more comparative speed test
- children and siblings speed fixes
- init support for HTML collections
- pseudo selector speed improvements
- fixed an issue in .match() that incorrectly detected forms as arrays
- speed fixes
- extend updated
- upgrades to .off() event removal
- updated gulp file for inclusion of liscence
- small bug fixes
- updated documantation and tests
- speed updates
- added filter by function
- updated find to include elements not in the dom
- more consistent documentation
- more consistent output
- updated filter method
- updated find method
- support for css4 selectors
- µ.matches for css selector matching
- depreciated selector generation
- fixed a bug in microbe creation when the scope was a microbe
- many core speed fixes
- added debounce
- added insertStyle
- added once
- added poll
- added prepend
- added removeStyle
- added removeStyles
- addClass now accepts className strings
- removeClass now accepts className strings and arrays
- attr now accepts objects
- html now accepts microbes
- many documentation updates
- added pseudo selector support
- added filter function
- added find function
- many documentation updates
No one should be using less than 0.3 Changes past that will be posted here.