{"name":"dom101","description":"DOM manipulation functions.","version":"2.2.1","author":{"name":"Rico Sta. Cruz","email":"rico@ricostacruz.com"},"bugs":{"url":"https://github.com/rstacruz/dom101/issues"},"devDependencies":{"docpress":"0.6.13","git-update-ghpages":"1.3.0","jest":"21.2.1","mdx":"0.3.1","npm-run-all":"4.1.1","prettier-standard":"7.0.1","standard":"10.0.3"},"directories":{"test":"test"},"homepage":"https://ricostacruz.com/dom101","keywords":["addclass","dom","helpers","html","jquery","removeclass","utils"],"license":"MIT","main":"index.js","repository":{"type":"git","url":"git+https://github.com/rstacruz/dom101.git"},"scripts":{"test":"jest","lint":"standard","prepare":"make -B prepare"},"gitHead":"9afd10c27a82c812d964635ba825b32863b2c736","_id":"dom101@2.2.1","_npmVersion":"5.3.0","_nodeVersion":"8.3.0","_npmUser":{"name":"rstacruz","email":"dropbox@ricostacruz.com"},"dist":{"integrity":"sha512-xPZjrYTprHPipC6z30X9LfKhkFeI6ESzMxSise6mqwqYC05MuDC0m0djEJ6cFVKhIPzUfonmnSm0z9Jgn84c1w==","shasum":"16bdf36daf58a5846f72f3d8e48ba0ec1b186330","tarball":"http://registry-npm.ywwl.com/dom101/download/dom101-2.2.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC+XruLHkqgrtRE0X1w9rLUssDSdVA74v5MludieMkKbgIgJekozhHm9pSIInFwljYb5GRWTbpziOhPDi/woi/LGp4="}],"size":76111,"noattachment":false,"key":"/dom101/-/dom101-2.2.1.tgz"},"maintainers":[{"email":"dropbox@ricostacruz.com","name":"rstacruz"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dom101-2.2.1.tgz_1508211629113_0.3071373088750988"},"readme":"# dom101\n\n<!-- {.massive-header.-with-tagline} -->\n\n> DOM manipulation utilities\n\ndom101 is a set of utilities for manipulating the DOM as single files.<br>\n*aka: Stop using jQuery.*\n\n```js\nvar addClass = require('dom101/add-class');\n\nel = document.createElement('div');\naddClass(el, 'active');\n```\n\n[![Status](https://travis-ci.org/rstacruz/dom101.svg?branch=master)](https://travis-ci.org/rstacruz/dom101)  \n\n## Why?\n\nIf you're writing a frontend library, it's best to avoid a dependency on\n[jQuery]. This means having to write your own DOM manipulation code,\nthough. To speed you along, I've packaged all that typical DOM\nmanipulation code into many single-use JS files.\n\n> #### Slim builds\n> You can use [browserify] to make your final bundle and it\n> will only bundle the functions it needs, instead of bundling a monolithic\n> jQuery.\n> \n> #### Copy-pastable\n> If you don't want to include dom101 as a dependency, each\n> file ([example]) stand on their own and can be easily pasted into your project.\n> \n> #### Semi-legacy support\n> Minimum browser fully-supported is IE8, with most of the utilities\n> working with even older IE versions.\n\ndom101 loosely follows the conventions of [101].\n\n## Reference\n\n| jQuery                      | dom101                                 |\n| ------                      | ------                                 |\n| `$(el).addClass('...')`     | [addClass](#addclass)(el, '...')       |\n| `$(el).hasClass('...')`     | [hasClass](#hasclass)(el, '...')       |\n| `$(el).removeClass('...')`  | [removeClass](#removeclass)(el, '...') |\n| `$(el).toggleClass('...')`  | [toggleClass](#toggleclass)(el, '...') |\n| `$(el).remove()`            | [remove](#remove)(el)                  |\n| `$(el).text()`              | [text](#text)(el)                      |\n| `$(el).text('...')`         | [text](#text)(el, '...')               |\n| `$(el).before(newEl)`       | [before](#before)(el, newEl)           |\n| `$(el).after(newEl)`        | [after](#after)(el, newEl)             |\n| `$(el).on('click', fn)`     | [on](#on)(el, 'click', fn)             |\n| `$(fn)`                     | [ready](#ready)(fn)                    |\n| `$(document).ready(fn)`     | [ready](#ready)(fn)                    |\n| `$(document).height()`      | [documentHeight](#documentheight)()    |\n| `$(document).width()`       | [documentWidth](#documentwidth)()      |\n| `$(el).outerHeight()`       | [outerHeight](#outerheight)(el)        |\n| `$(el).outerWidth()`        | [outerWidth](#outerwidth)(el)          |\n| `$(el).prepend(child)`      | [prepend](#prepend)(el, child)         |\n| `$(el).trigger('click')`    | [trigger](#trigger)(el, 'click')       |\n| `$(el).closest('selector')` | [closest](#closest)(el, 'selector')    |\n| `$(el).is('selector')`      | [matches](#matches)(el, 'selector')    |\n\n### Non-DOM utilities\n\n| jQuery                 | dom101                               |\n| ------                 | ------                               |\n| `$.each(list, fn)`     | [each](#each)(list, fn)              |\n| `$.map(list, fn)`      | [map](#map)(list, fn)                |\n| `$.extend(...)`        | [extend](#extend)(...)               |\n| `$.extend(true, ...)`  | [deepExtend](#deepextend)(...)       |\n| `$.isPlainObject(obj)` | [isPlainObject](#isplainobject)(obj) |\n\n### Aliases\n\nSome aliases for DOM functions are also added for convenience.\n\n| DOM                              | dom101                                     |\n| ---                              | ------                                     |\n| `document.querySelector(...)`    | [querySelector](#queryselector)(...)       |\n| `document.querySelectorAll(...)` | [querySelectorAll](#queryselectorall)(...) |\n\n### Not implemented\n\nSome DOM helpers aren't implemented, because they're easy enough to do with plain DOM API:\n\n| jQuery                              | DOM                                |\n| ------                              | ---                                |\n| `$('...')`                          | `document.querySelectorAll('...')` |\n| `$(el).attr('tabindex')`            | `el.getAttribute('tabindex')`      |\n| `$(el).attr('tabindex', 3)`         | `el.setAttribute('tabindex', 3)`   |\n| `$(el).css('border-radius', '3px')` | `el.style.borderRadius = '3px'`    |\n| `$(el).html()`                      | `el.innerHTML`                     |\n| `$(el).html('...')`                 | `el.innerHTML = '...'`             |\n| `$(el).parent()`                    | `el.parentNode`                    |\n| `$(el).clone()`                     | `el.cloneNode(true)`               |\n| `$(el).children()`                  | `el.children`                      |\n| `$el.find('...')`                   | `el.querySelectorAll('...')`       |\n| `$el.blur()`                        | `el.blur()`                        |\n| `$el.focus()`                       | `el.focus()`                       |\n| `$el.append(child)`                 | `el.appendChild(child)`            |\n| `$el.prop('checked')`               | `el.checked`                       |\n| `$el.prop('checked', true)`         | `el.checked = true`                |\n| `$el.prop('disabled')`              | `el.disabled`                      |\n| `$el.prop('disabled', true)`        | `el.disabled = true`               |\n\n## Install\n\ndom101 is available via [npm]. Perfect for use with [browserify].\n\n    $ npm install --save dom101\n\n[npm]: https://www.npmjs.org/package/dom101\n[browserify]: https://browserify.org\n\n[![npm version](http://img.shields.io/npm/v/dom101.svg?style=flat)](https://npmjs.org/package/dom101 \"View this project on npm\")\n\n## API Reference\n\n<!--api-->\n\n### addClass\n\n> `addClass(el, className)`\n\nAdds a class name to an element. Compare with `$.fn.addClass`.\n\n```js\nvar addClass = require('dom101/add-class');\n\naddClass(el, 'active');\n```\n\n### after\n\n> `after(el, newEl)`\n\nInserts a new element `newEl` just after `el`.\n\n```js\nvar after = require('dom101/after');\nvar newNode = document.createElement('div');\nvar button = document.querySelector('#submit');\n\nafter(button, newNode);\n```\n\n### before\n\n> `before(el, newEl)`\n\nInserts a new element `newEl` just before `el`.\n\n```js\nvar before = require('dom101/before');\nvar newNode = document.createElement('div');\nvar button = document.querySelector('#submit');\n\nbefore(button, newNode);\n```\n\n### closest\n\n> `closest(el, selector)`\n\nLooks for the closest ancestor of element `el` that matches `selector`.\nCompare with [$.fn.closest](http://api.jquery.com/closest/).\n\n```js\nvar closest = require('dom101/closest');\n\nclosest(input, 'label');\n```\n\n### deepExtend\n\n> `deepExtend(dest, src1, [src2 ...])`\n\nExtends object `dest` with properties from sources `src`.\nCompare with [$.extend(true)](http://api.jquery.com/jquery.extend/).\nAlso consider [deep-extend].\n\n[deep-extend]: http://npmjs.com/deep-extend\n\n```js\nvar deepExtend = require('dom101/deep-extend');\ndeepExtend({}, defaults, options);\n```\n\n### documentHeight\n\n> `documentHeight()`\n\nReturns the height of the document.\nCompare with jQuery's `$(document).height()`.\n\n```js\nvar documentHeight = require('dom101/document-height');\n\nvar height = documentHeight();\n```\n\n### documentWidth\n\n> `documentWidth()`\n\nReturns the width of the document.\nCompare with jQuery's `$(document).width()`.\n\n```js\nvar documentWidth = require('dom101/document-width');\n\nvar width = documentWidth();\n```\n\n### each\n\n> `each(list, fn)`\n\nIterates through `list` (an array or an object). This is useful when dealing\nwith NodeLists like `document.querySelectorAll`.\n\n```js\nvar each = require('dom101/each');\nvar qa = require('dom101/query-selector-all');\n\neach(qa('.button'), function (el) {\n  addClass('el', 'selected');\n});\n```\n\n### extend\n\n> `extend(dest, src1, [src2 ...])`\n\nExtends object `dest` with properties from sources `src`.\nCompare with [$.extend](http://api.jquery.com/jquery.extend/).\nAlso consider [object-assign] and the built-in `Object.assign`.\n\n[object-assign]: http://npmjs.com/object-assign\n\n```js\nvar extend = require('dom101/extend');\nextend({}, defaults, options);\n```\n\n### hasClass\n\n> `hasClass(el, className)`\n\nChecks if an element has a given class name.\n\n```js\nvar hasClass = require('dom101/has-class');\n\nel.className = 'selected active';\nhasClass(el, 'active') //=> true\n```\n\n### exports\n\nthis file is only provided for convenience and for tests.\nit's not advised to use it.\n\n### isPlainObject\n\n> `isPlainObject(obj)`\n\nChecks if `obj` is an object created with `{}` or `new Object`.\nCompare with [$.isPlainObject](http://api.jquery.com/jquery.isplainobject/).\n\n```js\nvar isPlainObject = require('dom101/is-plain-object');\n\nisPlainObject({}) //=> true\nisPlainObject([]) //=> false\n```\n\n### map\n\n> `map(list, fn)`\n\nIterates through `list` (an array or an object).\n\n```js\nvar map = require('dom101/map');\nvar text = require('dom101/text');\n\nmap(qa('.button'), function (el) {\n  return text(el);\n});\n```\n\n### matches\n\n> `matches(el, selector)`\n\nChecks if a given element `el` matches `selector`.\nCompare with [$.fn.is](http://api.jquery.com/is/).\n\n```js\nvar matches = require('dom101/matches');\n\nmatches(button, ':focus');\n```\n\n### nextUntil\n\n> `nextUntil(el, selector)`\n\nReturns all elements next to element `el`, until it reaches `selector` or\nthe end of the sibling list of `el`.\n\n```js\nnextUntil(li, 'li:last-child')\n```\n\n### on\n\n> `on(el, event, fn)`\n\nAdds an event handler.\n\n```js\nvar on = require('dom101/on');\n\non(el, 'click', function () {\n  ...\n});\n```\n\n### outerHeight\n\n> `outerHeight(el, includeMargin)`\n\nReturns the outer height (height + padding [+margin]) of an element as an\ninteger. Supports IE8+.\n\nIf `includeMargin` is true, then margins will be part of the computation.\n\n```js\nvar outerHeight = require('dom101/outer-height');\nvar height = outerHeight(el);\nvar fullHeight = outerHeight(el, true);  // include margins\n```\n\n### outerWidth\n\n> `outerWidth(el, includeMargin)`\n\nReturns the outer width (width + padding [+margin]) of an element as an\ninteger. Supports IE8+.\n\nIf `includeMargin` is true, then margins will be part of the computation.\n\n```js\nvar outerWidth = require('dom101/outer-width');\nvar width = outerWidth(el);\nvar fullWidth = outerWidth(el);  // include margins\n```\n\n### prepend\n\n> `prepend(el, child)`\n\nPrepends a `child` into a parent `el`. Compare with `$.fn.prepend`.\n\n```js\nvar prepend = require('dom101/prepend');\n\nprepend(el, child);\n```\n\n### querySelectorAll\n\n> `querySelectorAll(query, [element])`\n\nConvenience function to access `document.querySelectorAll`. Unlike the\ndefault version, this always returns an array.\n\nIf a 2nd parameter `element` is given, it only searches for descendants of\nthat element.\n\n```js\nvar each = require('dom101/each');\nvar qsa = require('dom101/query-selector-all');\n\nqsa('.button').each(el => {\n  addClass('el', 'selected');\n};\n```\n\n### querySelector\n\n> `querySelector(query)`\n\nConvenience function to access `document.querySelector`.\n\n```js\nvar q = require('dom101/query-selector');\naddClass(q('#instructions'), 'hidden');\n```\n\n### ready\n\n> `ready(fn)`\n\nExecutes `fn` when the DOM is ready. If the DOM is already ready, the given\ncallback will be called immediately.\n\n```js\nvar ready = require('dom101/ready');\n\nready(function () {\n  ...\n});\n```\n\n### removeClass\n\n> `removeClass(el, className)`\n\nRemoves a classname.\n\n```js\nvar removeClass = require('dom101/remove-class');\n\nel.className = 'selected active';\nremoveClass(el, 'active');\n\nel.className\n=> \"selected\"\n```\n\n### remove\n\n> `remove(el)`\n\nRemoves an element from the DOM.\n\n```js\nvar remove = require('dom101/remove');\n\nremove(el);\n```\n\n### scrollTop\n\n> `scrollTop()`\n\nReturns the scroll top value.\n\n```js\nvar scrollTop = require('dom101/scroll-top');\nalert(scrollTop());\n```\n\n### text\n\n> `text(el, [value])`\n\nSets or gets text. Compare with `$.fn.text`.\n\n```js\nvar text = require('dom101/text');\n\ntext(el, 'Hello');\n\ntext(el)\n=> \"Hello\"\n```\n\n### toggleClass\n\n> `toggleClass(el, className, [value])`\n\nAdds or removes a class name to an element. If `value` is provided,\nthis will add the class if it's `true` or remove if it's `false`.\nCompare with `$.fn.toggleClass`.\n\n```js\nvar toggleClass = require('dom101/toggle-class');\n\n// toggles on or off:\ntoggleClass(el, 'active');\n\n// with a value:\nvar isSelected = true;\ntoggleClass(el, 'selected', isSelected);\n```\n\n### trigger\n\n> `trigger(el, event)`\n\nTriggers an event `event`. Only works for native events.\n\n```js\nvar trigger = require('dom101/trigger');\n\nel = document.querySelector('#button');\ntrigger(el, 'click');\n```\n<!--api:end-->\n\n## Similar projects\n\n * [jQuery] (of course)\n * [youmightnotneedjquery.com] — actually takes a bunch of code from here\n * [101]\n * [bonzo]\n\n## Thanks\n\n**dom101** © 2014+, Rico Sta. Cruz. Released under the [MIT] License.<br>\nAuthored and maintained by Rico Sta. Cruz with help from contributors ([list][contributors]).\n\n> [ricostacruz.com](http://ricostacruz.com) &nbsp;&middot;&nbsp;\n> GitHub [@rstacruz](https://github.com/rstacruz) &nbsp;&middot;&nbsp;\n> Twitter [@rstacruz](https://twitter.com/rstacruz)\n\n[MIT]: http://mit-license.org/\n[contributors]: http://github.com/rstacruz/dom101/contributors\n\n[jQuery]: http://jquery.com\n[browserify]: http://browserify.org\n[101]: https://www.npmjs.org/package/101\n[youmightnotneedjquery.com]: http://youmightnotneedjquery.com/\n[example]: https://github.com/rstacruz/dom101/blob/master/add-class.js\n[bonzo]: https://github.com/ded/bonzo\n","publish_time":1508211629189,"_cnpm_publish_time":1508211629189,"dist-tags":{"latest":"2.2.1"}}