single-file-core 1.6.10 → 1.6.11

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 +7 -2
  2. package/package.json +1 -1
package/core/index.js CHANGED
@@ -1799,15 +1799,20 @@ function getNestingPositions(doc) {
1799
1799
  return Array.from(doc.querySelectorAll(`[${util.NESTING_TRACK_ID_ATTRIBUTE_NAME}]`)).map(element => ({
1800
1800
  element,
1801
1801
  parentNode: element.parentNode,
1802
+ previousSibling: element.previousSibling,
1802
1803
  nextSibling: element.nextSibling
1803
1804
  }));
1804
1805
  }
1805
1806
 
1806
1807
  function restoreNestingPositions(positions) {
1807
1808
  if (positions) {
1808
- positions.slice().reverse().forEach(({ element, parentNode, nextSibling }) => {
1809
+ positions.forEach(({ element, parentNode, previousSibling, nextSibling }) => {
1809
1810
  if (element.isConnected && parentNode && parentNode.isConnected) {
1810
- if (nextSibling && nextSibling.parentNode == parentNode) {
1811
+ if (previousSibling && previousSibling.parentNode == parentNode) {
1812
+ parentNode.insertBefore(element, previousSibling.nextSibling);
1813
+ } else if (!previousSibling) {
1814
+ parentNode.insertBefore(element, parentNode.firstChild);
1815
+ } else if (nextSibling && nextSibling.parentNode == parentNode) {
1811
1816
  parentNode.insertBefore(element, nextSibling);
1812
1817
  } else {
1813
1818
  parentNode.appendChild(element);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.6.10",
3
+ "version": "1.6.11",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",