source: imaps-frontend/node_modules/html2canvas/dist/lib/dom/node-parser.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 7.8 KB
RevLine 
[79a0317]1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.isCustomElement = exports.isSlotElement = exports.isSelectElement = exports.isTextareaElement = exports.isScriptElement = exports.isStyleElement = exports.isIFrameElement = exports.isImageElement = exports.isVideoElement = exports.isCanvasElement = exports.isBodyElement = exports.isSVGElement = exports.isHTMLElement = exports.isInputElement = exports.isOLElement = exports.isLIElement = exports.isSVGElementNode = exports.isHTMLElementNode = exports.isElementNode = exports.isTextNode = exports.parseTree = void 0;
4var element_container_1 = require("./element-container");
5var text_container_1 = require("./text-container");
6var image_element_container_1 = require("./replaced-elements/image-element-container");
7var canvas_element_container_1 = require("./replaced-elements/canvas-element-container");
8var svg_element_container_1 = require("./replaced-elements/svg-element-container");
9var li_element_container_1 = require("./elements/li-element-container");
10var ol_element_container_1 = require("./elements/ol-element-container");
11var input_element_container_1 = require("./replaced-elements/input-element-container");
12var select_element_container_1 = require("./elements/select-element-container");
13var textarea_element_container_1 = require("./elements/textarea-element-container");
14var iframe_element_container_1 = require("./replaced-elements/iframe-element-container");
15var LIST_OWNERS = ['OL', 'UL', 'MENU'];
16var parseNodeTree = function (context, node, parent, root) {
17 for (var childNode = node.firstChild, nextNode = void 0; childNode; childNode = nextNode) {
18 nextNode = childNode.nextSibling;
19 if (exports.isTextNode(childNode) && childNode.data.trim().length > 0) {
20 parent.textNodes.push(new text_container_1.TextContainer(context, childNode, parent.styles));
21 }
22 else if (exports.isElementNode(childNode)) {
23 if (exports.isSlotElement(childNode) && childNode.assignedNodes) {
24 childNode.assignedNodes().forEach(function (childNode) { return parseNodeTree(context, childNode, parent, root); });
25 }
26 else {
27 var container = createContainer(context, childNode);
28 if (container.styles.isVisible()) {
29 if (createsRealStackingContext(childNode, container, root)) {
30 container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
31 }
32 else if (createsStackingContext(container.styles)) {
33 container.flags |= 2 /* CREATES_STACKING_CONTEXT */;
34 }
35 if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) {
36 container.flags |= 8 /* IS_LIST_OWNER */;
37 }
38 parent.elements.push(container);
39 childNode.slot;
40 if (childNode.shadowRoot) {
41 parseNodeTree(context, childNode.shadowRoot, container, root);
42 }
43 else if (!exports.isTextareaElement(childNode) &&
44 !exports.isSVGElement(childNode) &&
45 !exports.isSelectElement(childNode)) {
46 parseNodeTree(context, childNode, container, root);
47 }
48 }
49 }
50 }
51 }
52};
53var createContainer = function (context, element) {
54 if (exports.isImageElement(element)) {
55 return new image_element_container_1.ImageElementContainer(context, element);
56 }
57 if (exports.isCanvasElement(element)) {
58 return new canvas_element_container_1.CanvasElementContainer(context, element);
59 }
60 if (exports.isSVGElement(element)) {
61 return new svg_element_container_1.SVGElementContainer(context, element);
62 }
63 if (exports.isLIElement(element)) {
64 return new li_element_container_1.LIElementContainer(context, element);
65 }
66 if (exports.isOLElement(element)) {
67 return new ol_element_container_1.OLElementContainer(context, element);
68 }
69 if (exports.isInputElement(element)) {
70 return new input_element_container_1.InputElementContainer(context, element);
71 }
72 if (exports.isSelectElement(element)) {
73 return new select_element_container_1.SelectElementContainer(context, element);
74 }
75 if (exports.isTextareaElement(element)) {
76 return new textarea_element_container_1.TextareaElementContainer(context, element);
77 }
78 if (exports.isIFrameElement(element)) {
79 return new iframe_element_container_1.IFrameElementContainer(context, element);
80 }
81 return new element_container_1.ElementContainer(context, element);
82};
83var parseTree = function (context, element) {
84 var container = createContainer(context, element);
85 container.flags |= 4 /* CREATES_REAL_STACKING_CONTEXT */;
86 parseNodeTree(context, element, container, container);
87 return container;
88};
89exports.parseTree = parseTree;
90var createsRealStackingContext = function (node, container, root) {
91 return (container.styles.isPositionedWithZIndex() ||
92 container.styles.opacity < 1 ||
93 container.styles.isTransformed() ||
94 (exports.isBodyElement(node) && root.styles.isTransparent()));
95};
96var createsStackingContext = function (styles) { return styles.isPositioned() || styles.isFloating(); };
97var isTextNode = function (node) { return node.nodeType === Node.TEXT_NODE; };
98exports.isTextNode = isTextNode;
99var isElementNode = function (node) { return node.nodeType === Node.ELEMENT_NODE; };
100exports.isElementNode = isElementNode;
101var isHTMLElementNode = function (node) {
102 return exports.isElementNode(node) && typeof node.style !== 'undefined' && !exports.isSVGElementNode(node);
103};
104exports.isHTMLElementNode = isHTMLElementNode;
105var isSVGElementNode = function (element) {
106 return typeof element.className === 'object';
107};
108exports.isSVGElementNode = isSVGElementNode;
109var isLIElement = function (node) { return node.tagName === 'LI'; };
110exports.isLIElement = isLIElement;
111var isOLElement = function (node) { return node.tagName === 'OL'; };
112exports.isOLElement = isOLElement;
113var isInputElement = function (node) { return node.tagName === 'INPUT'; };
114exports.isInputElement = isInputElement;
115var isHTMLElement = function (node) { return node.tagName === 'HTML'; };
116exports.isHTMLElement = isHTMLElement;
117var isSVGElement = function (node) { return node.tagName === 'svg'; };
118exports.isSVGElement = isSVGElement;
119var isBodyElement = function (node) { return node.tagName === 'BODY'; };
120exports.isBodyElement = isBodyElement;
121var isCanvasElement = function (node) { return node.tagName === 'CANVAS'; };
122exports.isCanvasElement = isCanvasElement;
123var isVideoElement = function (node) { return node.tagName === 'VIDEO'; };
124exports.isVideoElement = isVideoElement;
125var isImageElement = function (node) { return node.tagName === 'IMG'; };
126exports.isImageElement = isImageElement;
127var isIFrameElement = function (node) { return node.tagName === 'IFRAME'; };
128exports.isIFrameElement = isIFrameElement;
129var isStyleElement = function (node) { return node.tagName === 'STYLE'; };
130exports.isStyleElement = isStyleElement;
131var isScriptElement = function (node) { return node.tagName === 'SCRIPT'; };
132exports.isScriptElement = isScriptElement;
133var isTextareaElement = function (node) { return node.tagName === 'TEXTAREA'; };
134exports.isTextareaElement = isTextareaElement;
135var isSelectElement = function (node) { return node.tagName === 'SELECT'; };
136exports.isSelectElement = isSelectElement;
137var isSlotElement = function (node) { return node.tagName === 'SLOT'; };
138exports.isSlotElement = isSlotElement;
139// https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
140var isCustomElement = function (node) { return node.tagName.indexOf('-') > 0; };
141exports.isCustomElement = isCustomElement;
142//# sourceMappingURL=node-parser.js.map
Note: See TracBrowser for help on using the repository browser.