document-cloner.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. "use strict";
  2. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  3. return new (P || (P = Promise))(function (resolve, reject) {
  4. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  5. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  6. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  7. step((generator = generator.apply(thisArg, _arguments || [])).next());
  8. });
  9. };
  10. var __generator = (this && this.__generator) || function (thisArg, body) {
  11. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  12. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  13. function verb(n) { return function (v) { return step([n, v]); }; }
  14. function step(op) {
  15. if (f) throw new TypeError("Generator is already executing.");
  16. while (_) try {
  17. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  18. if (y = 0, t) op = [op[0] & 2, t.value];
  19. switch (op[0]) {
  20. case 0: case 1: t = op; break;
  21. case 4: _.label++; return { value: op[1], done: false };
  22. case 5: _.label++; y = op[1]; op = [0]; continue;
  23. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  24. default:
  25. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  26. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  27. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  28. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  29. if (t[2]) _.ops.pop();
  30. _.trys.pop(); continue;
  31. }
  32. op = body.call(thisArg, _);
  33. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  34. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  35. }
  36. };
  37. Object.defineProperty(exports, "__esModule", { value: true });
  38. var node_parser_1 = require("./node-parser");
  39. var logger_1 = require("../core/logger");
  40. var parser_1 = require("../css/syntax/parser");
  41. var tokenizer_1 = require("../css/syntax/tokenizer");
  42. var counter_1 = require("../css/types/functions/counter");
  43. var list_style_type_1 = require("../css/property-descriptors/list-style-type");
  44. var index_1 = require("../css/index");
  45. var quotes_1 = require("../css/property-descriptors/quotes");
  46. var IGNORE_ATTRIBUTE = 'data-html2canvas-ignore';
  47. var DocumentCloner = /** @class */ (function () {
  48. function DocumentCloner(element, options) {
  49. this.options = options;
  50. this.scrolledElements = [];
  51. this.referenceElement = element;
  52. this.counters = new counter_1.CounterState();
  53. this.quoteDepth = 0;
  54. if (!element.ownerDocument) {
  55. throw new Error('Cloned element does not have an owner document');
  56. }
  57. this.documentElement = this.cloneNode(element.ownerDocument.documentElement);
  58. }
  59. DocumentCloner.prototype.toIFrame = function (ownerDocument, windowSize) {
  60. var _this = this;
  61. var iframe = createIFrameContainer(ownerDocument, windowSize);
  62. if (!iframe.contentWindow) {
  63. return Promise.reject("Unable to find iframe window");
  64. }
  65. var scrollX = ownerDocument.defaultView.pageXOffset;
  66. var scrollY = ownerDocument.defaultView.pageYOffset;
  67. var cloneWindow = iframe.contentWindow;
  68. var documentClone = cloneWindow.document;
  69. /* Chrome doesn't detect relative background-images assigned in inline <style> sheets when fetched through getComputedStyle
  70. if window url is about:blank, we can assign the url to current by writing onto the document
  71. */
  72. var iframeLoad = iframeLoader(iframe).then(function () { return __awaiter(_this, void 0, void 0, function () {
  73. var onclone;
  74. return __generator(this, function (_a) {
  75. switch (_a.label) {
  76. case 0:
  77. this.scrolledElements.forEach(restoreNodeScroll);
  78. if (cloneWindow) {
  79. cloneWindow.scrollTo(windowSize.left, windowSize.top);
  80. if (/(iPad|iPhone|iPod)/g.test(navigator.userAgent) &&
  81. (cloneWindow.scrollY !== windowSize.top || cloneWindow.scrollX !== windowSize.left)) {
  82. documentClone.documentElement.style.top = -windowSize.top + 'px';
  83. documentClone.documentElement.style.left = -windowSize.left + 'px';
  84. documentClone.documentElement.style.position = 'absolute';
  85. }
  86. }
  87. onclone = this.options.onclone;
  88. if (typeof this.clonedReferenceElement === 'undefined') {
  89. return [2 /*return*/, Promise.reject("Error finding the " + this.referenceElement.nodeName + " in the cloned document")];
  90. }
  91. if (!(documentClone.fonts && documentClone.fonts.ready)) return [3 /*break*/, 2];
  92. return [4 /*yield*/, documentClone.fonts.ready];
  93. case 1:
  94. _a.sent();
  95. _a.label = 2;
  96. case 2:
  97. if (typeof onclone === 'function') {
  98. return [2 /*return*/, Promise.resolve()
  99. .then(function () { return onclone(documentClone); })
  100. .then(function () { return iframe; })];
  101. }
  102. return [2 /*return*/, iframe];
  103. }
  104. });
  105. }); });
  106. documentClone.open();
  107. documentClone.write(serializeDoctype(document.doctype) + "<html></html>");
  108. // Chrome scrolls the parent document for some reason after the write to the cloned window???
  109. restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
  110. documentClone.replaceChild(documentClone.adoptNode(this.documentElement), documentClone.documentElement);
  111. documentClone.close();
  112. return iframeLoad;
  113. };
  114. DocumentCloner.prototype.createElementClone = function (node) {
  115. if (node_parser_1.isCanvasElement(node)) {
  116. return this.createCanvasClone(node);
  117. }
  118. /*
  119. if (isIFrameElement(node)) {
  120. return this.createIFrameClone(node);
  121. }
  122. */
  123. if (node_parser_1.isStyleElement(node)) {
  124. return this.createStyleClone(node);
  125. }
  126. var clone = node.cloneNode(false);
  127. // @ts-ignore
  128. if (node_parser_1.isImageElement(clone) && clone.loading === 'lazy') {
  129. // @ts-ignore
  130. clone.loading = 'eager';
  131. }
  132. return clone;
  133. };
  134. DocumentCloner.prototype.createStyleClone = function (node) {
  135. try {
  136. var sheet = node.sheet;
  137. if (sheet && sheet.cssRules) {
  138. var css = [].slice.call(sheet.cssRules, 0).reduce(function (css, rule) {
  139. if (rule && typeof rule.cssText === 'string') {
  140. return css + rule.cssText;
  141. }
  142. return css;
  143. }, '');
  144. var style = node.cloneNode(false);
  145. style.textContent = css;
  146. return style;
  147. }
  148. }
  149. catch (e) {
  150. // accessing node.sheet.cssRules throws a DOMException
  151. logger_1.Logger.getInstance(this.options.id).error('Unable to access cssRules property', e);
  152. if (e.name !== 'SecurityError') {
  153. throw e;
  154. }
  155. }
  156. return node.cloneNode(false);
  157. };
  158. DocumentCloner.prototype.createCanvasClone = function (canvas) {
  159. if (this.options.inlineImages && canvas.ownerDocument) {
  160. var img = canvas.ownerDocument.createElement('img');
  161. try {
  162. img.src = canvas.toDataURL();
  163. return img;
  164. }
  165. catch (e) {
  166. logger_1.Logger.getInstance(this.options.id).info("Unable to clone canvas contents, canvas is tainted");
  167. }
  168. }
  169. var clonedCanvas = canvas.cloneNode(false);
  170. try {
  171. clonedCanvas.width = canvas.width;
  172. clonedCanvas.height = canvas.height;
  173. var ctx = canvas.getContext('2d');
  174. var clonedCtx = clonedCanvas.getContext('2d');
  175. if (clonedCtx) {
  176. if (ctx) {
  177. clonedCtx.putImageData(ctx.getImageData(0, 0, canvas.width, canvas.height), 0, 0);
  178. }
  179. else {
  180. clonedCtx.drawImage(canvas, 0, 0);
  181. }
  182. }
  183. return clonedCanvas;
  184. }
  185. catch (e) { }
  186. return clonedCanvas;
  187. };
  188. /*
  189. createIFrameClone(iframe: HTMLIFrameElement) {
  190. const tempIframe = <HTMLIFrameElement>iframe.cloneNode(false);
  191. const iframeKey = generateIframeKey();
  192. tempIframe.setAttribute('data-html2canvas-internal-iframe-key', iframeKey);
  193. const {width, height} = parseBounds(iframe);
  194. this.resourceLoader.cache[iframeKey] = getIframeDocumentElement(iframe, this.options)
  195. .then(documentElement => {
  196. return this.renderer(
  197. documentElement,
  198. {
  199. allowTaint: this.options.allowTaint,
  200. backgroundColor: '#ffffff',
  201. canvas: null,
  202. imageTimeout: this.options.imageTimeout,
  203. logging: this.options.logging,
  204. proxy: this.options.proxy,
  205. removeContainer: this.options.removeContainer,
  206. scale: this.options.scale,
  207. foreignObjectRendering: this.options.foreignObjectRendering,
  208. useCORS: this.options.useCORS,
  209. target: new CanvasRenderer(),
  210. width,
  211. height,
  212. x: 0,
  213. y: 0,
  214. windowWidth: documentElement.ownerDocument.defaultView.innerWidth,
  215. windowHeight: documentElement.ownerDocument.defaultView.innerHeight,
  216. scrollX: documentElement.ownerDocument.defaultView.pageXOffset,
  217. scrollY: documentElement.ownerDocument.defaultView.pageYOffset
  218. },
  219. );
  220. })
  221. .then(
  222. (canvas: HTMLCanvasElement) =>
  223. new Promise((resolve, reject) => {
  224. const iframeCanvas = document.createElement('img');
  225. iframeCanvas.onload = () => resolve(canvas);
  226. iframeCanvas.onerror = (event) => {
  227. // Empty iframes may result in empty "data:," URLs, which are invalid from the <img>'s point of view
  228. // and instead of `onload` cause `onerror` and unhandled rejection warnings
  229. // https://github.com/niklasvh/html2canvas/issues/1502
  230. iframeCanvas.src == 'data:,' ? resolve(canvas) : reject(event);
  231. };
  232. iframeCanvas.src = canvas.toDataURL();
  233. if (tempIframe.parentNode && iframe.ownerDocument && iframe.ownerDocument.defaultView) {
  234. tempIframe.parentNode.replaceChild(
  235. copyCSSStyles(
  236. iframe.ownerDocument.defaultView.getComputedStyle(iframe),
  237. iframeCanvas
  238. ),
  239. tempIframe
  240. );
  241. }
  242. })
  243. );
  244. return tempIframe;
  245. }
  246. */
  247. DocumentCloner.prototype.cloneNode = function (node) {
  248. if (node_parser_1.isTextNode(node)) {
  249. return document.createTextNode(node.data);
  250. }
  251. if (!node.ownerDocument) {
  252. return node.cloneNode(false);
  253. }
  254. var window = node.ownerDocument.defaultView;
  255. if (window && node_parser_1.isElementNode(node) && (node_parser_1.isHTMLElementNode(node) || node_parser_1.isSVGElementNode(node))) {
  256. var clone = this.createElementClone(node);
  257. var style = window.getComputedStyle(node);
  258. var styleBefore = window.getComputedStyle(node, ':before');
  259. var styleAfter = window.getComputedStyle(node, ':after');
  260. if (this.referenceElement === node && node_parser_1.isHTMLElementNode(clone)) {
  261. this.clonedReferenceElement = clone;
  262. }
  263. if (node_parser_1.isBodyElement(clone)) {
  264. createPseudoHideStyles(clone);
  265. }
  266. var counters = this.counters.parse(new index_1.CSSParsedCounterDeclaration(style));
  267. var before = this.resolvePseudoContent(node, clone, styleBefore, PseudoElementType.BEFORE);
  268. for (var child = node.firstChild; child; child = child.nextSibling) {
  269. if (!node_parser_1.isElementNode(child) ||
  270. (!node_parser_1.isScriptElement(child) &&
  271. !child.hasAttribute(IGNORE_ATTRIBUTE) &&
  272. (typeof this.options.ignoreElements !== 'function' || !this.options.ignoreElements(child)))) {
  273. if (!this.options.copyStyles || !node_parser_1.isElementNode(child) || !node_parser_1.isStyleElement(child)) {
  274. clone.appendChild(this.cloneNode(child));
  275. }
  276. }
  277. }
  278. if (before) {
  279. clone.insertBefore(before, clone.firstChild);
  280. }
  281. var after = this.resolvePseudoContent(node, clone, styleAfter, PseudoElementType.AFTER);
  282. if (after) {
  283. clone.appendChild(after);
  284. }
  285. this.counters.pop(counters);
  286. if (style && (this.options.copyStyles || node_parser_1.isSVGElementNode(node)) && !node_parser_1.isIFrameElement(node)) {
  287. exports.copyCSSStyles(style, clone);
  288. }
  289. //this.inlineAllImages(clone);
  290. if (node.scrollTop !== 0 || node.scrollLeft !== 0) {
  291. this.scrolledElements.push([clone, node.scrollLeft, node.scrollTop]);
  292. }
  293. if ((node_parser_1.isTextareaElement(node) || node_parser_1.isSelectElement(node)) &&
  294. (node_parser_1.isTextareaElement(clone) || node_parser_1.isSelectElement(clone))) {
  295. clone.value = node.value;
  296. }
  297. return clone;
  298. }
  299. return node.cloneNode(false);
  300. };
  301. DocumentCloner.prototype.resolvePseudoContent = function (node, clone, style, pseudoElt) {
  302. var _this = this;
  303. if (!style) {
  304. return;
  305. }
  306. var value = style.content;
  307. var document = clone.ownerDocument;
  308. if (!document || !value || value === 'none' || value === '-moz-alt-content' || style.display === 'none') {
  309. return;
  310. }
  311. this.counters.parse(new index_1.CSSParsedCounterDeclaration(style));
  312. var declaration = new index_1.CSSParsedPseudoDeclaration(style);
  313. var anonymousReplacedElement = document.createElement('html2canvaspseudoelement');
  314. exports.copyCSSStyles(style, anonymousReplacedElement);
  315. declaration.content.forEach(function (token) {
  316. if (token.type === tokenizer_1.TokenType.STRING_TOKEN) {
  317. anonymousReplacedElement.appendChild(document.createTextNode(token.value));
  318. }
  319. else if (token.type === tokenizer_1.TokenType.URL_TOKEN) {
  320. var img = document.createElement('img');
  321. img.src = token.value;
  322. img.style.opacity = '1';
  323. anonymousReplacedElement.appendChild(img);
  324. }
  325. else if (token.type === tokenizer_1.TokenType.FUNCTION) {
  326. if (token.name === 'attr') {
  327. var attr = token.values.filter(parser_1.isIdentToken);
  328. if (attr.length) {
  329. anonymousReplacedElement.appendChild(document.createTextNode(node.getAttribute(attr[0].value) || ''));
  330. }
  331. }
  332. else if (token.name === 'counter') {
  333. var _a = token.values.filter(parser_1.nonFunctionArgSeparator), counter = _a[0], counterStyle = _a[1];
  334. if (counter && parser_1.isIdentToken(counter)) {
  335. var counterState = _this.counters.getCounterValue(counter.value);
  336. var counterType = counterStyle && parser_1.isIdentToken(counterStyle)
  337. ? list_style_type_1.listStyleType.parse(counterStyle.value)
  338. : list_style_type_1.LIST_STYLE_TYPE.DECIMAL;
  339. anonymousReplacedElement.appendChild(document.createTextNode(counter_1.createCounterText(counterState, counterType, false)));
  340. }
  341. }
  342. else if (token.name === 'counters') {
  343. var _b = token.values.filter(parser_1.nonFunctionArgSeparator), counter = _b[0], delim = _b[1], counterStyle = _b[2];
  344. if (counter && parser_1.isIdentToken(counter)) {
  345. var counterStates = _this.counters.getCounterValues(counter.value);
  346. var counterType_1 = counterStyle && parser_1.isIdentToken(counterStyle)
  347. ? list_style_type_1.listStyleType.parse(counterStyle.value)
  348. : list_style_type_1.LIST_STYLE_TYPE.DECIMAL;
  349. var separator = delim && delim.type === tokenizer_1.TokenType.STRING_TOKEN ? delim.value : '';
  350. var text = counterStates
  351. .map(function (value) { return counter_1.createCounterText(value, counterType_1, false); })
  352. .join(separator);
  353. anonymousReplacedElement.appendChild(document.createTextNode(text));
  354. }
  355. }
  356. else {
  357. // console.log('FUNCTION_TOKEN', token);
  358. }
  359. }
  360. else if (token.type === tokenizer_1.TokenType.IDENT_TOKEN) {
  361. switch (token.value) {
  362. case 'open-quote':
  363. anonymousReplacedElement.appendChild(document.createTextNode(quotes_1.getQuote(declaration.quotes, _this.quoteDepth++, true)));
  364. break;
  365. case 'close-quote':
  366. anonymousReplacedElement.appendChild(document.createTextNode(quotes_1.getQuote(declaration.quotes, --_this.quoteDepth, false)));
  367. break;
  368. default:
  369. // safari doesn't parse string tokens correctly because of lack of quotes
  370. anonymousReplacedElement.appendChild(document.createTextNode(token.value));
  371. }
  372. }
  373. });
  374. anonymousReplacedElement.className = PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
  375. var newClassName = pseudoElt === PseudoElementType.BEFORE
  376. ? " " + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE
  377. : " " + PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
  378. if (node_parser_1.isSVGElementNode(clone)) {
  379. clone.className.baseValue += newClassName;
  380. }
  381. else {
  382. clone.className += newClassName;
  383. }
  384. return anonymousReplacedElement;
  385. };
  386. DocumentCloner.destroy = function (container) {
  387. if (container.parentNode) {
  388. container.parentNode.removeChild(container);
  389. return true;
  390. }
  391. return false;
  392. };
  393. return DocumentCloner;
  394. }());
  395. exports.DocumentCloner = DocumentCloner;
  396. var PseudoElementType;
  397. (function (PseudoElementType) {
  398. PseudoElementType[PseudoElementType["BEFORE"] = 0] = "BEFORE";
  399. PseudoElementType[PseudoElementType["AFTER"] = 1] = "AFTER";
  400. })(PseudoElementType || (PseudoElementType = {}));
  401. var createIFrameContainer = function (ownerDocument, bounds) {
  402. var cloneIframeContainer = ownerDocument.createElement('iframe');
  403. cloneIframeContainer.className = 'html2canvas-container';
  404. cloneIframeContainer.style.visibility = 'hidden';
  405. cloneIframeContainer.style.position = 'fixed';
  406. cloneIframeContainer.style.left = '-10000px';
  407. cloneIframeContainer.style.top = '0px';
  408. cloneIframeContainer.style.border = '0';
  409. cloneIframeContainer.width = bounds.width.toString();
  410. cloneIframeContainer.height = bounds.height.toString();
  411. cloneIframeContainer.scrolling = 'no'; // ios won't scroll without it
  412. cloneIframeContainer.setAttribute(IGNORE_ATTRIBUTE, 'true');
  413. ownerDocument.body.appendChild(cloneIframeContainer);
  414. return cloneIframeContainer;
  415. };
  416. var iframeLoader = function (iframe) {
  417. return new Promise(function (resolve, reject) {
  418. var cloneWindow = iframe.contentWindow;
  419. if (!cloneWindow) {
  420. return reject("No window assigned for iframe");
  421. }
  422. var documentClone = cloneWindow.document;
  423. cloneWindow.onload = iframe.onload = documentClone.onreadystatechange = function () {
  424. cloneWindow.onload = iframe.onload = documentClone.onreadystatechange = null;
  425. var interval = setInterval(function () {
  426. if (documentClone.body.childNodes.length > 0 && documentClone.readyState === 'complete') {
  427. clearInterval(interval);
  428. resolve(iframe);
  429. }
  430. }, 50);
  431. };
  432. });
  433. };
  434. exports.copyCSSStyles = function (style, target) {
  435. // Edge does not provide value for cssText
  436. for (var i = style.length - 1; i >= 0; i--) {
  437. var property = style.item(i);
  438. // Safari shows pseudoelements if content is set
  439. if (property !== 'content') {
  440. target.style.setProperty(property, style.getPropertyValue(property));
  441. }
  442. }
  443. return target;
  444. };
  445. var serializeDoctype = function (doctype) {
  446. var str = '';
  447. if (doctype) {
  448. str += '<!DOCTYPE ';
  449. if (doctype.name) {
  450. str += doctype.name;
  451. }
  452. if (doctype.internalSubset) {
  453. str += doctype.internalSubset;
  454. }
  455. if (doctype.publicId) {
  456. str += "\"" + doctype.publicId + "\"";
  457. }
  458. if (doctype.systemId) {
  459. str += "\"" + doctype.systemId + "\"";
  460. }
  461. str += '>';
  462. }
  463. return str;
  464. };
  465. var restoreOwnerScroll = function (ownerDocument, x, y) {
  466. if (ownerDocument &&
  467. ownerDocument.defaultView &&
  468. (x !== ownerDocument.defaultView.pageXOffset || y !== ownerDocument.defaultView.pageYOffset)) {
  469. ownerDocument.defaultView.scrollTo(x, y);
  470. }
  471. };
  472. var restoreNodeScroll = function (_a) {
  473. var element = _a[0], x = _a[1], y = _a[2];
  474. element.scrollLeft = x;
  475. element.scrollTop = y;
  476. };
  477. var PSEUDO_BEFORE = ':before';
  478. var PSEUDO_AFTER = ':after';
  479. var PSEUDO_HIDE_ELEMENT_CLASS_BEFORE = '___html2canvas___pseudoelement_before';
  480. var PSEUDO_HIDE_ELEMENT_CLASS_AFTER = '___html2canvas___pseudoelement_after';
  481. var PSEUDO_HIDE_ELEMENT_STYLE = "{\n content: \"\" !important;\n display: none !important;\n}";
  482. var createPseudoHideStyles = function (body) {
  483. createStyles(body, "." + PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + PSEUDO_BEFORE + PSEUDO_HIDE_ELEMENT_STYLE + "\n ." + PSEUDO_HIDE_ELEMENT_CLASS_AFTER + PSEUDO_AFTER + PSEUDO_HIDE_ELEMENT_STYLE);
  484. };
  485. var createStyles = function (body, styles) {
  486. var document = body.ownerDocument;
  487. if (document) {
  488. var style = document.createElement('style');
  489. style.textContent = styles;
  490. body.appendChild(style);
  491. }
  492. };
  493. //# sourceMappingURL=document-cloner.js.map