Skip to content

Commit

Permalink
remove forEach and Map, update style and display functions
Browse files Browse the repository at this point in the history
  • Loading branch information
aksanoble committed May 21, 2015
1 parent e751ebd commit a77a936
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
4 changes: 0 additions & 4 deletions README.md
Expand Up @@ -18,10 +18,6 @@ tinix is a tiny library of shortcuts for vanilla JavaScript DOM. If all your app
Same as `document.querySelector`
#### $.all(selector)
Same as `document.querySelectorAll`
#### $.forEach(selector, callback)
`callback` is called with each `Element` of the `NodeList` matching `selector`.
#### $.map(selector, callback)
`callback` is called with each `Element` of the `NodeList` matching `selector`. Returns `Array`.
#### $.style(selector, property, value)
Changes the selector(s) style.property to value.
#### $.display(selector, value)
Expand Down
23 changes: 10 additions & 13 deletions tinix.js
Expand Up @@ -15,27 +15,24 @@ if (tinix.supported && !Element.prototype.on) {
Element.prototype.on = Element.prototype.addEventListener
}

if (tinix.supported && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = Array.prototype.forEach
}

tinix.all = function(selector, elem) {
elem = elem || document
return elem.querySelectorAll(selector)
}

tinix.forEach = function(selector, elem, func) {
Array.prototype.forEach.call(this.all(selector, elem), func)
}

tinix.map = function(selector, func) {
return Array.prototype.map.call(this.all(selector), func)
}

tinix.style = function(selector, iteratee, val) {
this.forEach(s, function(elem) {
elem.style[iteratee] = val
})
tinix.style = function(selector, elem, key, val) {
this.all(selector, elem).forEach(function(el){
el.style[key] = val;
})
}

tinix.display = function(selector, val) {
this.style(selector, "display", val)
tinix.display = function(selector, elem, val) {
this.style(selector, elem, "display", val)
}

tinix.ready = function(func) {
Expand Down

0 comments on commit a77a936

Please sign in to comment.