var NodeContainer = require('./nodecontainer'); function PseudoElementContainer(node, parent, type) { NodeContainer.call(this, node, parent); this.isPseudoElement = true; this.before = type === ":before"; } PseudoElementContainer.prototype.cloneTo = function(stack) { PseudoElementContainer.prototype.cloneTo.call(this, stack); stack.isPseudoElement = true; stack.before = this.before; }; PseudoElementContainer.prototype = Object.create(NodeContainer.prototype); PseudoElementContainer.prototype.appendToDOM = function() { if (this.before) { this.parent.node.insertBefore(this.node, this.parent.node.firstChild); } else { this.parent.node.appendChild(this.node); } this.parent.node.className += " " + this.getHideClass(); }; PseudoElementContainer.prototype.cleanDOM = function() { this.node.parentNode.removeChild(this.node); this.parent.node.className = this.parent.node.className.replace(this.getHideClass(), ""); }; PseudoElementContainer.prototype.getHideClass = function() { return this["PSEUDO_HIDE_ELEMENT_CLASS_" + (this.before ? "BEFORE" : "AFTER")]; }; PseudoElementContainer.prototype.PSEUDO_HIDE_ELEMENT_CLASS_BEFORE = "___html2canvas___pseudoelement_before"; PseudoElementContainer.prototype.PSEUDO_HIDE_ELEMENT_CLASS_AFTER = "___html2canvas___pseudoelement_after"; module.exports = PseudoElementContainer;