Slide 11
Slide 11 text
HTMLElement.prototype.replicate = function () {
var dupe = this.cloneNode(true),
walker = document.createTreeWalker(this, NodeFilter.SHOW_ELEMENT, null),
dupeWalker = document.createTreeWalker(dupe, NodeFilter.SHOW_ELEMENT, null);
!
function copyStyle(fromNode, toNode) {
toNode.style.cssText = window.getComputedStyle(fromNode, null).cssText;
return toNode;
}
!
copyStyle(this, dupe);
!
while(walker.nextNode()) {
copyStyle(walker.currentNode, dupeWalker.nextNode());
}
!
return dupe;
}
gist.github.com/mwunsch/8830293