|
|
|
|
|
by tshadwell
4081 days ago
|
|
Or, you know, use the Javascript DOM APIs? They're really not at all that bad. var d = document.createElement("div");
d.className = "new";
d.innerHTML = "<p>Hi Sprint</p>";
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:function toArray(o) { return Array.prototype.slice.call(o) } Instead it's: var toArray = function(obj) {
var arr = []
var i = obj.length
while (i--) {
arr[i] = obj[i]
}
return arr
}
This is just silly: prepend: function() {
insertHTML.call(this, "afterbegin", arguments)
return this
},
var insertHTML = function(position, args) {
var argsLen = args.length
var contents = args
[...] var domMethods = {
afterbegin: function(el) {
this.insertBefore(el, this.firstChild)
},
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 like Javascript, I just wish people would learn how to work with the language it instead of replacing the API wholesale. |
|
Modifying your example:
Vesus: