iframe-element-container.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. Object.defineProperty(exports, "__esModule", { value: true });
  18. exports.IFrameElementContainer = void 0;
  19. var element_container_1 = require("../element-container");
  20. var node_parser_1 = require("../node-parser");
  21. var color_1 = require("../../css/types/color");
  22. var IFrameElementContainer = /** @class */ (function (_super) {
  23. __extends(IFrameElementContainer, _super);
  24. function IFrameElementContainer(context, iframe) {
  25. var _this = _super.call(this, context, iframe) || this;
  26. _this.src = iframe.src;
  27. _this.width = parseInt(iframe.width, 10) || 0;
  28. _this.height = parseInt(iframe.height, 10) || 0;
  29. _this.backgroundColor = _this.styles.backgroundColor;
  30. try {
  31. if (iframe.contentWindow &&
  32. iframe.contentWindow.document &&
  33. iframe.contentWindow.document.documentElement) {
  34. _this.tree = node_parser_1.parseTree(context, iframe.contentWindow.document.documentElement);
  35. // http://www.w3.org/TR/css3-background/#special-backgrounds
  36. var documentBackgroundColor = iframe.contentWindow.document.documentElement
  37. ? color_1.parseColor(context, getComputedStyle(iframe.contentWindow.document.documentElement).backgroundColor)
  38. : color_1.COLORS.TRANSPARENT;
  39. var bodyBackgroundColor = iframe.contentWindow.document.body
  40. ? color_1.parseColor(context, getComputedStyle(iframe.contentWindow.document.body).backgroundColor)
  41. : color_1.COLORS.TRANSPARENT;
  42. _this.backgroundColor = color_1.isTransparent(documentBackgroundColor)
  43. ? color_1.isTransparent(bodyBackgroundColor)
  44. ? _this.styles.backgroundColor
  45. : bodyBackgroundColor
  46. : documentBackgroundColor;
  47. }
  48. }
  49. catch (e) { }
  50. return _this;
  51. }
  52. return IFrameElementContainer;
  53. }(element_container_1.ElementContainer));
  54. exports.IFrameElementContainer = IFrameElementContainer;
  55. //# sourceMappingURL=iframe-element-container.js.map