00ed86a74bc5fe86fc733f4bf0f8cb0d12fe8a98.svn-base 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. var NodeContainer = require('./nodecontainer');
  2. function PseudoElementContainer(node, parent, type) {
  3. NodeContainer.call(this, node, parent);
  4. this.isPseudoElement = true;
  5. this.before = type === ":before";
  6. }
  7. PseudoElementContainer.prototype.cloneTo = function(stack) {
  8. PseudoElementContainer.prototype.cloneTo.call(this, stack);
  9. stack.isPseudoElement = true;
  10. stack.before = this.before;
  11. };
  12. PseudoElementContainer.prototype = Object.create(NodeContainer.prototype);
  13. PseudoElementContainer.prototype.appendToDOM = function() {
  14. if (this.before) {
  15. this.parent.node.insertBefore(this.node, this.parent.node.firstChild);
  16. } else {
  17. this.parent.node.appendChild(this.node);
  18. }
  19. this.parent.node.className += " " + this.getHideClass();
  20. };
  21. PseudoElementContainer.prototype.cleanDOM = function() {
  22. this.node.parentNode.removeChild(this.node);
  23. this.parent.node.className = this.parent.node.className.replace(this.getHideClass(), "");
  24. };
  25. PseudoElementContainer.prototype.getHideClass = function() {
  26. return this["PSEUDO_HIDE_ELEMENT_CLASS_" + (this.before ? "BEFORE" : "AFTER")];
  27. };
  28. PseudoElementContainer.prototype.PSEUDO_HIDE_ELEMENT_CLASS_BEFORE = "___html2canvas___pseudoelement_before";
  29. PseudoElementContainer.prototype.PSEUDO_HIDE_ELEMENT_CLASS_AFTER = "___html2canvas___pseudoelement_after";
  30. module.exports = PseudoElementContainer;