Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Remove {NodeList,NamedNodeMap,HTMLCollection}.forEach, use .array ins…
Browse files Browse the repository at this point in the history
…tead
  • Loading branch information
dfreedm committed Sep 24, 2013
1 parent 2b89598 commit a89ae7c
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,19 @@
oldName && this.remove(oldName);
newName && this.add(newName);
};
// add array() and forEach() to NodeList, NamedNodeMap, HTMLCollection

// add array() to NodeList, NamedNodeMap, HTMLCollection

var ArraySlice = function() {
return Array.prototype.slice.call(this);
};

var namedNodeMap = (window.NamedNodeMap || window.MozNamedAttrMap || {});

NodeList.prototype.array = ArraySlice;
namedNodeMap.prototype.array = ArraySlice;
HTMLCollection.prototype.array = ArraySlice;

var ArrayForEach = function(cb, context) {
ArraySlice.call(this).forEach(cb, context);
};

NodeList.prototype.forEach = ArrayForEach;
namedNodeMap.prototype.forEach = ArrayForEach;
HTMLCollection.prototype.forEach = ArrayForEach;

// polyfill performance.now

if (!window.performance) {
Expand Down Expand Up @@ -104,7 +96,7 @@
// utility

function createDOM(inTagOrNode, inHTML, inAttrs) {
var dom = typeof inTagOrNode == 'string' ?
var dom = typeof inTagOrNode == 'string' ?
document.createElement(inTagOrNode) : inTagOrNode.cloneNode(true);
dom.innerHTML = inHTML;
if (inAttrs) {
Expand Down

0 comments on commit a89ae7c

Please sign in to comment.