From 5ecb5b021c2ac9f859bcba664cc38fff7acb3e4e Mon Sep 17 00:00:00 2001
From: igor <igor.markin@vereign.com>
Date: Wed, 2 Dec 2020 13:53:16 +0300
Subject: [PATCH] Add missing build files

---
 .../strategies/nodesAmendingFunctions.d.ts    |  1 +
 .../strategies/nodesAmendingFunctions.js      | 36 +++++++++++++++++++
 2 files changed, 37 insertions(+)
 create mode 100644 dist/HTMLNormalizer/strategies/nodesAmendingFunctions.d.ts
 create mode 100644 dist/HTMLNormalizer/strategies/nodesAmendingFunctions.js

diff --git a/dist/HTMLNormalizer/strategies/nodesAmendingFunctions.d.ts b/dist/HTMLNormalizer/strategies/nodesAmendingFunctions.d.ts
new file mode 100644
index 0000000..edaf502
--- /dev/null
+++ b/dist/HTMLNormalizer/strategies/nodesAmendingFunctions.d.ts
@@ -0,0 +1 @@
+export declare const unwindTags: (node: Element | Document, tagName: string) => void;
diff --git a/dist/HTMLNormalizer/strategies/nodesAmendingFunctions.js b/dist/HTMLNormalizer/strategies/nodesAmendingFunctions.js
new file mode 100644
index 0000000..da12e8e
--- /dev/null
+++ b/dist/HTMLNormalizer/strategies/nodesAmendingFunctions.js
@@ -0,0 +1,36 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.unwindTags = void 0;
+const unwindTags = (node, tagName) => {
+    const tags = node.getElementsByTagName(tagName);
+    //Sort tags by depth to start unwinding the deepest ones, which does not contain nested spans
+    const tagsDepths = {};
+    Array.from(tags).forEach((span) => {
+        let descendant = span;
+        let parent = descendant.parentNode;
+        let depth = 0;
+        while (parent && descendant !== parent) {
+            descendant = parent;
+            parent = descendant.parentNode;
+            depth++;
+        }
+        if (!tagsDepths[depth]) {
+            tagsDepths[depth] = [];
+        }
+        tagsDepths[depth].push(span);
+    });
+    Object.keys(tagsDepths)
+        .sort((a, b) => parseInt(b) - parseInt(a))
+        .forEach((depth) => {
+        tagsDepths[depth].forEach((span) => {
+            let child = span.firstChild;
+            const parent = span.parentNode;
+            while (child) {
+                parent.insertBefore(child.cloneNode(true), span);
+                child = child.nextSibling;
+            }
+            span.parentNode.removeChild(span);
+        });
+    });
+};
+exports.unwindTags = unwindTags;
-- 
GitLab