native-document 1.0.34 → 1.0.35

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.
@@ -852,21 +852,26 @@ var NativeDocument = (function (exports) {
852
852
  element.nativeInsertBefore = element.insertBefore;
853
853
  element.nativeAppendChild = element.appendChild;
854
854
 
855
+ const isParentUniqueChild = (parent) => {
856
+ console.log('on passwr ici ', isUniqueChild || (parent.firstChild === anchorStart && parent.lastChild === anchorEnd));
857
+ return isUniqueChild || (parent.firstChild === anchorStart && parent.lastChild === anchorEnd);
858
+ };
859
+
855
860
  const insertBefore = function(parent, child, target) {
856
861
  const element = Validator.isElement(child) ? child : ElementCreator.getChild(child);
857
862
  if(parent === element) {
858
863
  parent.nativeInsertBefore(element, target);
859
864
  return;
860
865
  }
861
- if(isUniqueChild || target === anchorEnd) {
862
- parent.append(element, target);
866
+ if(isParentUniqueChild(parent)) {
867
+ parent.append(element, anchorEnd);
863
868
  return;
864
869
  }
865
870
  parent.insertBefore(element, target);
866
871
  };
867
872
 
868
873
  element.appendElement = function(child, before = null) {
869
- if(isUniqueChild) {
874
+ if(isParentUniqueChild(anchorEnd.parentNode)) {
870
875
  (before && before !== anchorEnd)
871
876
  ? anchorEnd.parentNode.insertBefore(child, anchorEnd)
872
877
  : anchorEnd.parentNode.append(child, anchorEnd);
@@ -894,7 +899,7 @@ var NativeDocument = (function (exports) {
894
899
  if(parent === element) {
895
900
  return;
896
901
  }
897
- if(isUniqueChild || (parent.firstChild === anchorStart && parent.lastChild === anchorEnd)) {
902
+ if(isParentUniqueChild(parent)) {
898
903
  parent.replaceChildren(anchorStart, anchorEnd);
899
904
  return;
900
905
  }
@@ -913,7 +918,7 @@ var NativeDocument = (function (exports) {
913
918
  if(parent === element) {
914
919
  return;
915
920
  }
916
- if(isUniqueChild) {
921
+ if(isParentUniqueChild(parent)) {
917
922
  parent.replaceChildren(anchorEnd, anchorEnd);
918
923
  return;
919
924
  }
@@ -936,7 +941,7 @@ var NativeDocument = (function (exports) {
936
941
  if(!parent) {
937
942
  return;
938
943
  }
939
- if(isUniqueChild || (parent.firstChild === anchorStart && parent.lastChild === anchorEnd)) {
944
+ if(isParentUniqueChild(parent)) {
940
945
  parent.replaceChildren(anchorStart, child, anchorEnd);
941
946
  return;
942
947
  }
@@ -1548,7 +1553,9 @@ var NativeDocument = (function (exports) {
1548
1553
  if(!$node) {
1549
1554
  $node = $fn(this);
1550
1555
  }
1551
- return clone($node, data);
1556
+ const cloneNode = clone($node, data);
1557
+ PluginsManager.emit('NodeTemplateInstanceCreated', cloneNode);
1558
+ return cloneNode;
1552
1559
  };
1553
1560
 
1554
1561
  const createBinding = (hydrateFunction, target) => {
@@ -1590,10 +1597,12 @@ var NativeDocument = (function (exports) {
1590
1597
 
1591
1598
  function useCache(fn) {
1592
1599
  let $cache = null;
1600
+ PluginsManager.emit('NodeTemplateStored', fn);
1593
1601
 
1594
1602
  return function(...args) {
1595
1603
  if(!$cache) {
1596
1604
  $cache = new TemplateCloner(fn);
1605
+ PluginsManager.emit('NodeTemplateCreated', $cache);
1597
1606
  }
1598
1607
 
1599
1608
  return $cache.clone(args);