single-file-core 1.10.0 → 1.10.1

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.
Files changed (2) hide show
  1. package/core/index.js +27 -2
  2. package/package.json +1 -1
package/core/index.js CHANGED
@@ -507,6 +507,20 @@ const SVG_NAMESPACE_URI = "http://www.w3.org/2000/svg";
507
507
  const UTF8_CHARSET = "utf-8";
508
508
  const TAINTED_CANVAS_WARNING_MESSAGE = "SingleFile: canvas elements tainted by a cross-origin resource, dropped from the page:";
509
509
  const EMPTY_RESOURCE = "data:,";
510
+ const HIDDEN_NODE_STYLE = [
511
+ ["visibility", "hidden"],
512
+ ["width", "0"],
513
+ ["height", "0"],
514
+ ["min-width", "0"],
515
+ ["min-height", "0"],
516
+ ["padding", "0"],
517
+ ["margin", "0"],
518
+ ["border", "0"],
519
+ ["overflow", "hidden"],
520
+ ["flex", "0 0 0px"],
521
+ ["font-size", "0"],
522
+ ["line-height", "0"]
523
+ ];
510
524
  const ORDER_DEPENDENT_RULE = /@(layer|import)\b/i;
511
525
  const MANIFEST_TOP_WINDOW_ID = "0";
512
526
  const WINDOW_ID_SEPARATOR = ".";
@@ -911,11 +925,22 @@ class Processor {
911
925
 
912
926
  function hideNode(node) {
913
927
  if (canHideNode(node)) {
914
- node.style.setProperty("display", "none", "important");
928
+ const tagName = node.tagName.toUpperCase();
929
+ if (tagName == "BR" || tagName == "WBR") {
930
+ node.style.setProperty("display", "none", "important");
931
+ } else {
932
+ HIDDEN_NODE_STYLE.forEach(([propertyName, value]) => node.style.setProperty(propertyName, value, "important"));
933
+ }
915
934
  node.removeAttribute("src");
916
935
  node.removeAttribute("srcset");
917
936
  node.removeAttribute("srcdoc");
918
- Array.from(node.childNodes).forEach(removeNode);
937
+ Array.from(node.childNodes).forEach(childNode => {
938
+ if (childNode.nodeType == 1) {
939
+ removeNode(childNode);
940
+ } else {
941
+ childNode.remove();
942
+ }
943
+ });
919
944
  }
920
945
  }
921
946
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",