Or, you know, use the Javascript DOM APIs? They're really not at all that bad.<p><pre><code> var d = document.createElement("div");
d.className = "new";
d.innerHTML = "<p>Hi Sprint</p>";
</code></pre>
Skimming through the code I'm not sure the authors really grok Javascript anyway, which might explain why they need a (pretty thin) custom API for the standard APIs. toArray should be simply this:<p>function toArray(o) { return Array.prototype.slice.call(o) }<p>Instead it's:<p><pre><code> var toArray = function(obj) {
var arr = []
var i = obj.length
while (i--) {
arr[i] = obj[i]
}
return arr
}
</code></pre>
This is just silly:<p><pre><code> prepend: function() {
insertHTML.call(this, "afterbegin", arguments)
return this
},
var insertHTML = function(position, args) {
var argsLen = args.length
var contents = args
</code></pre>
[...]<p><pre><code> var domMethods = {
afterbegin: function(el) {
this.insertBefore(el, this.firstChild)
},
</code></pre>
Perhaps this isn't so constructive and I should fork the library and annotate every method with its vanilla Javascript equivalent. I'm sure this post is non-constructive in some respects but I <i>like</i> Javascript, I just wish people would learn how to work with the language it instead of replacing the API wholesale.