single-file-core 1.0.48 → 1.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,7 +68,7 @@ const booleanAttributes = [
68
68
  "visible"
69
69
  ];
70
70
 
71
- const noWhitespaceCollapseElements = ["script", "style", "pre", "textarea"];
71
+ const noWhitespaceCollapseElements = ["SCRIPT", "STYLE", "PRE", "TEXTAREA"];
72
72
 
73
73
  // Source: https://www.w3.org/TR/html4/sgml/dtd.html#events (Generic Attributes)
74
74
  const safeToRemoveAttrs = [
@@ -90,10 +90,10 @@ const safeToRemoveAttrs = [
90
90
  ];
91
91
 
92
92
  const redundantAttributes = {
93
- "form": {
93
+ "FORM": {
94
94
  "method": "get"
95
95
  },
96
- "script": {
96
+ "SCRIPT": {
97
97
  "language": "javascript",
98
98
  "type": "text/javascript",
99
99
  // Remove attribute if the function returns false
@@ -103,11 +103,11 @@ const redundantAttributes = {
103
103
  return !node.getAttribute("src");
104
104
  }
105
105
  },
106
- "style": {
106
+ "STYLE": {
107
107
  "media": "all",
108
108
  "type": "text/css"
109
109
  },
110
- "link": {
110
+ "LINK": {
111
111
  "media": "all"
112
112
  }
113
113
  };
@@ -128,7 +128,7 @@ const modules = [
128
128
  removeEmptyAttributes,
129
129
  removeRedundantAttributes,
130
130
  compressJSONLD,
131
- node => mergeElements(node, "style", (node, previousSibling) => node.parentElement && node.parentElement.tagName == "HEAD" && node.media == previousSibling.media && node.title == previousSibling.title)
131
+ node => mergeElements(node, "style", (node, previousSibling) => node.parentElement && getTagName(node.parentElement) == "HEAD" && node.media == previousSibling.media && node.title == previousSibling.title)
132
132
  ];
133
133
 
134
134
  export {
@@ -169,7 +169,7 @@ function mergeTextNodes(node) {
169
169
  }
170
170
 
171
171
  function mergeElements(node, tagName, acceptMerge) {
172
- if (node.nodeType == Node_ELEMENT_NODE && node.tagName.toLowerCase() == tagName.toLowerCase()) {
172
+ if (node.nodeType == Node_ELEMENT_NODE && getTagName(node) == tagName.toUpperCase()) {
173
173
  let previousSibling = node.previousSibling;
174
174
  const previousSiblings = [];
175
175
  while (previousSibling && previousSibling.nodeType == Node_TEXT_NODE && !previousSibling.textContent.trim()) {
@@ -203,15 +203,15 @@ function collapseWhitespace(node, options) {
203
203
  }
204
204
 
205
205
  function getWhiteSpace(node) {
206
- return node.parentElement && node.parentElement.tagName == "HEAD" ? "\n" : " ";
206
+ return node.parentElement && getTagName(node.parentElement) == "HEAD" ? "\n" : " ";
207
207
  }
208
208
 
209
209
  function noWhitespaceCollapse(element) {
210
- return element && !noWhitespaceCollapseElements.includes(element.tagName.toLowerCase());
210
+ return element && !noWhitespaceCollapseElements.includes(getTagName(element));
211
211
  }
212
212
 
213
213
  function removeComments(node) {
214
- if (node.nodeType == Node_COMMENT_NODE && node.parentElement.tagName != "HTML") {
214
+ if (node.nodeType == Node_COMMENT_NODE && getTagName(node.parentElement) != "HTML") {
215
215
  return !node.textContent.toLowerCase().trim().startsWith("[if");
216
216
  }
217
217
  }
@@ -231,7 +231,7 @@ function removeEmptyAttributes(node) {
231
231
 
232
232
  function removeRedundantAttributes(node) {
233
233
  if (node.nodeType == Node_ELEMENT_NODE) {
234
- const tagRedundantAttributes = redundantAttributes[node.tagName.toLowerCase()];
234
+ const tagRedundantAttributes = redundantAttributes[getTagName(node)];
235
235
  if (tagRedundantAttributes) {
236
236
  Object.keys(tagRedundantAttributes).forEach(redundantAttributeName => {
237
237
  const tagRedundantAttributeValue = tagRedundantAttributes[redundantAttributeName];
@@ -244,7 +244,7 @@ function removeRedundantAttributes(node) {
244
244
  }
245
245
 
246
246
  function compressJSONLD(node) {
247
- if (node.nodeType == Node_ELEMENT_NODE && node.tagName == "SCRIPT" && node.type == "application/ld+json" && node.textContent.trim()) {
247
+ if (node.nodeType == Node_ELEMENT_NODE && getTagName(node) == "SCRIPT" && node.type == "application/ld+json" && node.textContent.trim()) {
248
248
  try {
249
249
  node.textContent = JSON.stringify(JSON.parse(node.textContent));
250
250
  } catch (error) {
@@ -259,4 +259,8 @@ function removeEmptyInlineElements(doc) {
259
259
  element.remove();
260
260
  }
261
261
  });
262
+ }
263
+
264
+ function getTagName(element) {
265
+ return element.tagName && element.tagName.toUpperCase();
262
266
  }
@@ -21,7 +21,7 @@
21
21
  * Source.
22
22
  */
23
23
 
24
- const SELF_CLOSED_TAG_NAMES = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
24
+ const SELF_CLOSED_TAG_NAMES = ["AREA", "BASE", "BR", "COL", "COMMAND", "EMBED", "HR", "IMG", "INPUT", "KEYGEN", "LINK", "META", "PARAM", "SOURCE", "TRACK", "WBR"];
25
25
 
26
26
  const Node_ELEMENT_NODE = 1;
27
27
  const Node_TEXT_NODE = 3;
@@ -29,31 +29,31 @@ const Node_COMMENT_NODE = 8;
29
29
 
30
30
  // see https://www.w3.org/TR/html5/syntax.html#optional-tags
31
31
  const OMITTED_START_TAGS = [
32
- { tagName: "head", accept: element => !element.childNodes.length || element.childNodes[0].nodeType == Node_ELEMENT_NODE },
33
- { tagName: "body", accept: element => !element.childNodes.length }
32
+ { tagName: "HEAD", accept: element => !element.childNodes.length || element.childNodes[0].nodeType == Node_ELEMENT_NODE },
33
+ { tagName: "BODY", accept: element => !element.childNodes.length }
34
34
  ];
35
35
  const OMITTED_END_TAGS = [
36
- { tagName: "html", accept: next => !next || next.nodeType != Node_COMMENT_NODE },
37
- { tagName: "head", accept: next => !next || (next.nodeType != Node_COMMENT_NODE && (next.nodeType != Node_TEXT_NODE || !startsWithSpaceChar(next.textContent))) },
38
- { tagName: "body", accept: next => !next || next.nodeType != Node_COMMENT_NODE },
39
- { tagName: "li", accept: (next, element) => (!next && element.parentElement && (element.parentElement.tagName == "UL" || element.parentElement.tagName == "OL")) || (next && ["LI"].includes(next.tagName)) },
40
- { tagName: "dt", accept: next => !next || ["DT", "DD"].includes(next.tagName) },
41
- { tagName: "p", accept: next => next && ["ADDRESS", "ARTICLE", "ASIDE", "BLOCKQUOTE", "DETAILS", "DIV", "DL", "FIELDSET", "FIGCAPTION", "FIGURE", "FOOTER", "FORM", "H1", "H2", "H3", "H4", "H5", "H6", "HEADER", "HR", "MAIN", "NAV", "OL", "P", "PRE", "SECTION", "TABLE", "UL"].includes(next.tagName) },
42
- { tagName: "dd", accept: next => !next || ["DT", "DD"].includes(next.tagName) },
43
- { tagName: "rt", accept: next => !next || ["RT", "RP"].includes(next.tagName) },
44
- { tagName: "rp", accept: next => !next || ["RT", "RP"].includes(next.tagName) },
45
- { tagName: "optgroup", accept: next => !next || ["OPTGROUP"].includes(next.tagName) },
46
- { tagName: "option", accept: next => !next || ["OPTION", "OPTGROUP"].includes(next.tagName) },
47
- { tagName: "colgroup", accept: next => !next || (next.nodeType != Node_COMMENT_NODE && (next.nodeType != Node_TEXT_NODE || !startsWithSpaceChar(next.textContent))) },
48
- { tagName: "caption", accept: next => !next || (next.nodeType != Node_COMMENT_NODE && (next.nodeType != Node_TEXT_NODE || !startsWithSpaceChar(next.textContent))) },
49
- { tagName: "thead", accept: next => !next || ["TBODY", "TFOOT"].includes(next.tagName) },
50
- { tagName: "tbody", accept: next => !next || ["TBODY", "TFOOT"].includes(next.tagName) },
51
- { tagName: "tfoot", accept: next => !next },
52
- { tagName: "tr", accept: next => !next || ["TR"].includes(next.tagName) },
53
- { tagName: "td", accept: next => !next || ["TD", "TH"].includes(next.tagName) },
54
- { tagName: "th", accept: next => !next || ["TD", "TH"].includes(next.tagName) }
36
+ { tagName: "HTML", accept: next => !next || next.nodeType != Node_COMMENT_NODE },
37
+ { tagName: "HEAD", accept: next => !next || (next.nodeType != Node_COMMENT_NODE && (next.nodeType != Node_TEXT_NODE || !startsWithSpaceChar(next.textContent))) },
38
+ { tagName: "BODY", accept: next => !next || next.nodeType != Node_COMMENT_NODE },
39
+ { tagName: "LI", accept: (next, element) => (!next && element.parentElement && (getTagName(element.parentElement) == "UL" || getTagName(element.parentElement) == "OL")) || (next && ["LI"].includes(getTagName(next))) },
40
+ { tagName: "DT", accept: next => !next || ["DT", "DD"].includes(getTagName(next)) },
41
+ { tagName: "P", accept: next => next && ["ADDRESS", "ARTICLE", "ASIDE", "BLOCKQUOTE", "DETAILS", "DIV", "DL", "FIELDSET", "FIGCAPTION", "FIGURE", "FOOTER", "FORM", "H1", "H2", "H3", "H4", "H5", "H6", "HEADER", "HR", "MAIN", "NAV", "OL", "P", "PRE", "SECTION", "TABLE", "UL"].includes(getTagName(next)) },
42
+ { tagName: "DD", accept: next => !next || ["DT", "DD"].includes(getTagName(next)) },
43
+ { tagName: "RT", accept: next => !next || ["RT", "RP"].includes(getTagName(next)) },
44
+ { tagName: "RP", accept: next => !next || ["RT", "RP"].includes(getTagName(next)) },
45
+ { tagName: "OPTGROUP", accept: next => !next || ["OPTGROUP"].includes(getTagName(next)) },
46
+ { tagName: "OPTION", accept: next => !next || ["OPTION", "OPTGROUP"].includes(getTagName(next)) },
47
+ { tagName: "COLGROUP", accept: next => !next || (next.nodeType != Node_COMMENT_NODE && (next.nodeType != Node_TEXT_NODE || !startsWithSpaceChar(next.textContent))) },
48
+ { tagName: "CAPTION", accept: next => !next || (next.nodeType != Node_COMMENT_NODE && (next.nodeType != Node_TEXT_NODE || !startsWithSpaceChar(next.textContent))) },
49
+ { tagName: "THEAD", accept: next => !next || ["TBODY", "TFOOT"].includes(getTagName(next)) },
50
+ { tagName: "TBODY", accept: next => !next || ["TBODY", "TFOOT"].includes(getTagName(next)) },
51
+ { tagName: "TFOOT", accept: next => !next },
52
+ { tagName: "TR", accept: next => !next || ["TR"].includes(getTagName(next)) },
53
+ { tagName: "TD", accept: next => !next || ["TD", "TH"].includes(getTagName(next)) },
54
+ { tagName: "TH", accept: next => !next || ["TD", "TH"].includes(getTagName(next)) }
55
55
  ];
56
- const TEXT_NODE_TAGS = ["style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext", "noscript"];
56
+ const TEXT_NODE_TAGS = ["STYLE", "SCRIPT", "XMP", "IFRAME", "NOEMBED", "NOFRAMES", "PLAINTEXT", "NOSCRIPT"];
57
57
 
58
58
  export {
59
59
  process
@@ -91,10 +91,10 @@ function serializeTextNode(textNode) {
91
91
  const parentNode = textNode.parentNode;
92
92
  let parentTagName;
93
93
  if (parentNode && parentNode.nodeType == Node_ELEMENT_NODE) {
94
- parentTagName = parentNode.tagName.toLowerCase();
94
+ parentTagName = getTagName(parentNode);
95
95
  }
96
96
  if (!parentTagName || TEXT_NODE_TAGS.includes(parentTagName)) {
97
- if (parentTagName == "script" || parentTagName == "style") {
97
+ if (parentTagName == "SCRIPT" || parentTagName == "STYLE") {
98
98
  return textNode.textContent.replace(/<\//gi, "<\\/").replace(/\/>/gi, "\\/>");
99
99
  }
100
100
  return textNode.textContent;
@@ -108,22 +108,22 @@ function serializeCommentNode(commentNode) {
108
108
  }
109
109
 
110
110
  function serializeElement(element, compressHTML, isSVG) {
111
- const tagName = element.tagName.toLowerCase();
112
- const omittedStartTag = compressHTML && OMITTED_START_TAGS.find(omittedStartTag => tagName == omittedStartTag.tagName && omittedStartTag.accept(element));
111
+ const tagName = getTagName(element);
112
+ const omittedStartTag = compressHTML && OMITTED_START_TAGS.find(omittedStartTag => tagName == getTagName(omittedStartTag) && omittedStartTag.accept(element));
113
113
  let content = "";
114
114
  if (!omittedStartTag || element.attributes.length) {
115
- content = "<" + tagName;
115
+ content = "<" + tagName.toLowerCase();
116
116
  Array.from(element.attributes).forEach(attribute => content += serializeAttribute(attribute, element, compressHTML));
117
117
  content += ">";
118
118
  }
119
- if (element.tagName == "TEMPLATE" && !element.childNodes.length) {
119
+ if (tagName == "TEMPLATE" && !element.childNodes.length) {
120
120
  content += element.innerHTML;
121
121
  } else {
122
122
  Array.from(element.childNodes).forEach(childNode => content += serialize(childNode, compressHTML, isSVG || tagName == "svg"));
123
123
  }
124
- const omittedEndTag = compressHTML && OMITTED_END_TAGS.find(omittedEndTag => tagName == omittedEndTag.tagName && omittedEndTag.accept(element.nextSibling, element));
124
+ const omittedEndTag = compressHTML && OMITTED_END_TAGS.find(omittedEndTag => tagName == getTagName(omittedEndTag) && omittedEndTag.accept(element.nextSibling, element));
125
125
  if (isSVG || (!omittedEndTag && !SELF_CLOSED_TAG_NAMES.includes(tagName))) {
126
- content += "</" + tagName + ">";
126
+ content += "</" + tagName.toLowerCase() + ">";
127
127
  }
128
128
  return content;
129
129
  }
@@ -177,4 +177,8 @@ function serializeAttribute(attribute, element, compressHTML) {
177
177
 
178
178
  function startsWithSpaceChar(textContent) {
179
179
  return Boolean(textContent.match(/^[ \t\n\f\r]/));
180
+ }
181
+
182
+ function getTagName(element) {
183
+ return element.tagName && element.tagName.toUpperCase();
180
184
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.0.48",
3
+ "version": "1.0.49",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",
@@ -98,7 +98,8 @@ function triggerLazyLoading(options) {
98
98
  mutation.target.setAttribute(helper.LAZY_SRC_ATTRIBUTE_NAME, mutation.target.src);
99
99
  mutation.target.addEventListener("load", onResourceLoad);
100
100
  }
101
- if (mutation.attributeName == "src" || mutation.attributeName == "srcset" || mutation.target.tagName == "SOURCE") {
101
+ if (mutation.attributeName == "src" || mutation.attributeName == "srcset" ||
102
+ (mutation.target.tagName && mutation.target.tagName.toUpperCase() == "SOURCE")) {
102
103
  return !mutation.target.classList || !mutation.target.classList.contains(helper.SINGLE_FILE_UI_ELEMENT_CLASS);
103
104
  }
104
105
  });
@@ -629,8 +629,8 @@ class Processor {
629
629
 
630
630
  function canHideNode(node) {
631
631
  if (node.nodeType == 1) {
632
- const tagName = node.tagName && node.tagName.toLowerCase();
633
- return tagName != "svg" && tagName != "style" && tagName != "link";
632
+ const tagName = node.tagName && node.tagName.toUpperCase();
633
+ return tagName != "SVG" && tagName != "STYLE" && tagName != "LINK";
634
634
  }
635
635
  }
636
636
  }
@@ -639,7 +639,7 @@ class Processor {
639
639
  if (this.options.posters) {
640
640
  this.doc.querySelectorAll("video, video > source").forEach(element => {
641
641
  let videoElement;
642
- if (element.tagName == "VIDEO") {
642
+ if (element.tagName.toUpperCase() == "VIDEO") {
643
643
  videoElement = element;
644
644
  } else {
645
645
  videoElement = element.parentElement;
@@ -919,7 +919,7 @@ class Processor {
919
919
  resolveHrefs() {
920
920
  this.doc.querySelectorAll("a[href], area[href], link[href]").forEach(element => {
921
921
  const href = element.getAttribute("href").trim();
922
- if (element.tagName == "LINK" && element.rel.includes("stylesheet")) {
922
+ if (element.tagName.toUpperCase() == "LINK" && element.rel.includes("stylesheet")) {
923
923
  if (this.options.saveOriginalURLs && !isDataURL(href)) {
924
924
  element.setAttribute("data-sf-original-href", href);
925
925
  }
@@ -950,7 +950,7 @@ class Processor {
950
950
  await Promise.all(
951
951
  Array.from(this.doc.querySelectorAll("video[src], video > source[src]")).map(async element => {
952
952
  let videoElement;
953
- if (element.tagName == "VIDEO") {
953
+ if (element.tagName.toUpperCase() == "VIDEO") {
954
954
  videoElement = element;
955
955
  } else {
956
956
  videoElement = element.parentElement;
@@ -1022,7 +1022,7 @@ class Processor {
1022
1022
  mediaText,
1023
1023
  scoped
1024
1024
  };
1025
- if (element.tagName == "LINK" && element.charset) {
1025
+ if (element.tagName.toUpperCase() == "LINK" && element.charset) {
1026
1026
  options.charset = element.charset;
1027
1027
  }
1028
1028
  await processElement(element, stylesheetInfo, this.stylesheets, this.baseURI, options, this.workStyleElement);
@@ -1050,7 +1050,7 @@ class Processor {
1050
1050
  let stylesheet;
1051
1051
  stylesheets.set(element, stylesheetInfo);
1052
1052
  if (!options.blockStylesheets) {
1053
- if (element.tagName == "LINK") {
1053
+ if (element.tagName.toUpperCase() == "LINK") {
1054
1054
  stylesheet = await ProcessorHelper.resolveLinkStylesheetURLs(element.href, baseURI, options, workStyleElement);
1055
1055
  } else {
1056
1056
  stylesheet = cssTree.parse(element.textContent, { context: "stylesheet", parseCustomProperty: true });
@@ -1076,7 +1076,7 @@ class Processor {
1076
1076
  const frameElements = Array.from(this.doc.querySelectorAll("iframe, frame, object[type=\"text/html\"][data]"));
1077
1077
  await Promise.all(
1078
1078
  frameElements.map(async frameElement => {
1079
- if (frameElement.tagName == "OBJECT") {
1079
+ if (frameElement.tagName.toUpperCase() == "OBJECT") {
1080
1080
  frameElement.setAttribute("data", "data:text/html,");
1081
1081
  } else {
1082
1082
  const src = frameElement.getAttribute("src");
@@ -1305,10 +1305,10 @@ class Processor {
1305
1305
  sandbox += " allow-scripts allow-same-origin";
1306
1306
  }
1307
1307
  frameElement.setAttribute("sandbox", sandbox);
1308
- if (frameElement.tagName == "OBJECT") {
1308
+ if (frameElement.tagName.toUpperCase() == "OBJECT") {
1309
1309
  frameElement.setAttribute("data", "data:text/html," + pageData.content);
1310
1310
  } else {
1311
- if (frameElement.tagName == "FRAME") {
1311
+ if (frameElement.tagName.toUpperCase() == "FRAME") {
1312
1312
  frameElement.setAttribute("src", "data:text/html," + pageData.content.replace(/%/g, "%25").replace(/#/g, "%23"));
1313
1313
  } else {
1314
1314
  frameElement.setAttribute("srcdoc", pageData.content);
@@ -1766,7 +1766,9 @@ class ProcessorHelper {
1766
1766
  // ignored
1767
1767
  }
1768
1768
  if (testValidURL(resourceURL)) {
1769
- let { content, indexResource, duplicate } = await batchRequest.addURL(resourceURL, { asBinary: true, expectedType, groupDuplicates: options.groupDuplicateImages && resourceElement.tagName == "IMG" && attributeName == "src" });
1769
+ let { content, indexResource, duplicate } = await batchRequest.addURL(
1770
+ resourceURL,
1771
+ { asBinary: true, expectedType, groupDuplicates: options.groupDuplicateImages && resourceElement.tagName.toUpperCase() == "IMG" && attributeName == "src" });
1770
1772
  if (originURL) {
1771
1773
  if (content == util.EMPTY_RESOURCE) {
1772
1774
  try {
@@ -191,7 +191,7 @@ function getElementsInfo(win, doc, element, options, data = { usedFonts: new Map
191
191
  computedStyle = getComputedStyle(win, element);
192
192
  if (element instanceof win.HTMLElement) {
193
193
  if (options.removeHiddenElements) {
194
- elementKept = ((ascendantHidden || element.closest("html > head")) && KEPT_TAG_NAMES.includes(element.tagName)) || element.closest("details");
194
+ elementKept = ((ascendantHidden || element.closest("html > head")) && KEPT_TAG_NAMES.includes(element.tagName.toUpperCase())) || element.closest("details");
195
195
  if (!elementKept) {
196
196
  elementHidden = ascendantHidden || testHiddenElement(element, computedStyle);
197
197
  if (elementHidden) {
@@ -253,7 +253,8 @@ function getElementsInfo(win, doc, element, options, data = { usedFonts: new Map
253
253
  }
254
254
 
255
255
  function getResourcesInfo(win, doc, element, options, data, elementHidden, computedStyle) {
256
- if (element.tagName == "CANVAS") {
256
+ const tagName = element.tagName && element.tagName.toUpperCase();
257
+ if (tagName == "CANVAS") {
257
258
  try {
258
259
  data.canvases.push({ dataURI: element.toDataURL("image/png", "") });
259
260
  element.setAttribute(CANVAS_ATTRIBUTE_NAME, data.canvases.length - 1);
@@ -262,7 +263,7 @@ function getResourcesInfo(win, doc, element, options, data, elementHidden, compu
262
263
  // ignored
263
264
  }
264
265
  }
265
- if (element.tagName == "IMG") {
266
+ if (tagName == "IMG") {
266
267
  const imageData = {
267
268
  currentSrc: elementHidden ?
268
269
  EMPTY_RESOURCE :
@@ -288,7 +289,7 @@ function getResourcesInfo(win, doc, element, options, data, elementHidden, compu
288
289
  }
289
290
  }
290
291
  }
291
- if (element.tagName == "VIDEO") {
292
+ if (tagName == "VIDEO") {
292
293
  const src = element.currentSrc;
293
294
  if (src && !src.startsWith("blob:") && !src.startsWith("data:")) {
294
295
  const computedStyle = getComputedStyle(win, element.parentNode);
@@ -318,13 +319,13 @@ function getResourcesInfo(win, doc, element, options, data, elementHidden, compu
318
319
  }
319
320
  }
320
321
  }
321
- if (element.tagName == "IFRAME") {
322
+ if (tagName == "IFRAME") {
322
323
  if (elementHidden && options.removeHiddenElements) {
323
324
  element.setAttribute(HIDDEN_FRAME_ATTRIBUTE_NAME, "");
324
325
  data.markedElements.push(element);
325
326
  }
326
327
  }
327
- if (element.tagName == "INPUT") {
328
+ if (tagName == "INPUT") {
328
329
  if (element.type != "password") {
329
330
  element.setAttribute(INPUT_VALUE_ATTRIBUTE_NAME, element.value);
330
331
  data.markedElements.push(element);
@@ -334,11 +335,11 @@ function getResourcesInfo(win, doc, element, options, data, elementHidden, compu
334
335
  data.markedElements.push(element);
335
336
  }
336
337
  }
337
- if (element.tagName == "TEXTAREA") {
338
+ if (tagName == "TEXTAREA") {
338
339
  element.setAttribute(INPUT_VALUE_ATTRIBUTE_NAME, element.value);
339
340
  data.markedElements.push(element);
340
341
  }
341
- if (element.tagName == "SELECT") {
342
+ if (tagName == "SELECT") {
342
343
  element.querySelectorAll("option").forEach(option => {
343
344
  if (option.selected) {
344
345
  option.setAttribute(INPUT_VALUE_ATTRIBUTE_NAME, "");
@@ -346,7 +347,7 @@ function getResourcesInfo(win, doc, element, options, data, elementHidden, compu
346
347
  }
347
348
  });
348
349
  }
349
- if (element.tagName == "SCRIPT") {
350
+ if (tagName == "SCRIPT") {
350
351
  if (element.async && element.getAttribute("async") != "" && element.getAttribute("async") != "async") {
351
352
  element.setAttribute(ASYNC_SCRIPT_ATTRIBUTE_NAME, "");
352
353
  data.markedElements.push(element);