vanilla-js
Version:
jQuery-like Aliases (NOT Wrappers) to HTML5 Selector API / Raw Document
40 lines (29 loc) • 1.36 kB
Markdown
jQuery-like Aliases (NOT Wrappers) to HTML5 Selector API / Raw Document
* Cross-browser compatible*
* *HTML5 Selector API is [IE8+](http://www.webdirections.org/blog/html5-selectors-api-its-like-a-swiss-army-knife-for-the-dom/)
* *XMLHttpRequest is [IE7+](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest)
* *Element.prototype is [IE8+](http://msdn.microsoft.com/en-us/library/dd282900%28VS.85%29.aspx)
* Forget chaining; its [too expensive](http://jsperf.com/jqm3/85)
Inspired by the classic parody [vanilla-js.com](http://vanilla-js.com/).
```coffeescript
$.xhr 'GET', 'http://coffeescript.org/robots.txt', '', (err, data, status, xhr) ->
return console.log err, data, status, xhr, xhr.readyState, xhr.status if err
console.log status
console.log data
p = $.liveTag('p')
pp = $.all('p')
console.log p.length
console.log pp.length
console.log $.create('p').appendTo($.one('body'))
console.log p.length
console.log pp.length
```
Commented code is in [./coffee/](https://github.com/mikesmullin/vanilla-js/blob/stable/coffee/)
* [quirksmode.org](http://www.quirksmode.org/dom/w3c_html.html)