native-document 1.0.106 → 1.0.108

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.
@@ -643,7 +643,6 @@ var NativeComponents = (function (exports) {
643
643
 
644
644
  function NDElement(element) {
645
645
  this.$element = element;
646
- this.$observer = null;
647
646
  }
648
647
 
649
648
  NDElement.prototype.__$isNDElement = true;
@@ -658,7 +657,7 @@ var NativeComponents = (function (exports) {
658
657
  };
659
658
 
660
659
  NDElement.prototype.refSelf = function(target, name) {
661
- target[name] = this;
660
+ target[name] = new NDElement(this.$element);
662
661
  return this;
663
662
  };
664
663
 
@@ -679,23 +678,28 @@ var NativeComponents = (function (exports) {
679
678
  let element = this.$element;
680
679
  element.nd.unmountChildren();
681
680
  element.$ndProx = null;
682
- delete element.nd?.on?.prevent;
683
- delete element.nd?.on;
684
- delete element.nd;
681
+
682
+ $lifeCycleObservers.delete(element);
683
+
685
684
  element = null;
686
685
  return this;
687
686
  };
688
687
 
688
+ const $lifeCycleObservers = new WeakMap();
689
689
  NDElement.prototype.lifecycle = function(states) {
690
- this.$observer = this.$observer || DocumentObserver.watch(this.$element);
690
+ const el = this.$element;
691
+ if (!$lifeCycleObservers.has(el)) {
692
+ $lifeCycleObservers.set(el, DocumentObserver.watch(el));
693
+ }
694
+ const observer = $lifeCycleObservers.get(el);
691
695
 
692
696
  if(states.mounted) {
693
697
  this.$element.setAttribute('data--nd-mounted', '1');
694
- this.$observer.mounted(states.mounted);
698
+ observer.mounted(states.mounted);
695
699
  }
696
700
  if(states.unmounted) {
697
701
  this.$element.setAttribute('data--nd-unmounted', '1');
698
- this.$observer.unmounted(states.unmounted);
702
+ observer.unmounted(states.unmounted);
699
703
  }
700
704
  return this;
701
705
  };
@@ -2727,10 +2731,11 @@ var NativeComponents = (function (exports) {
2727
2731
 
2728
2732
  NDElement.prototype.transitionOut = function(transitionName) {
2729
2733
  const exitClass = transitionName + '-exit';
2734
+ const el = this.$element;
2730
2735
  this.beforeUnmount('transition-exit', async function() {
2731
- this.$element.classes.add(exitClass);
2732
- await waitForVisualEnd(this.$element);
2733
- this.$element.classes.remove(exitClass);
2736
+ el.classes.add(exitClass);
2737
+ await waitForVisualEnd(el);
2738
+ el.classes.remove(exitClass);
2734
2739
  });
2735
2740
  return this;
2736
2741
  };
@@ -2739,16 +2744,18 @@ var NativeComponents = (function (exports) {
2739
2744
  const startClass = transitionName + '-enter-from';
2740
2745
  const endClass = transitionName + '-enter-to';
2741
2746
 
2742
- this.$element.classes.add(startClass);
2747
+ const el = this.$element;
2748
+
2749
+ el.classes.add(startClass);
2743
2750
 
2744
2751
  this.mounted(() => {
2745
2752
  requestAnimationFrame(() => {
2746
2753
  requestAnimationFrame(() => {
2747
- this.$element.classes.remove(startClass);
2748
- this.$element.classes.add(endClass);
2754
+ el.classes.remove(startClass);
2755
+ el.classes.add(endClass);
2749
2756
 
2750
- waitForVisualEnd(this.$element).then(() => {
2751
- this.$element.classes.remove(endClass);
2757
+ waitForVisualEnd(el).then(() => {
2758
+ el.classes.remove(endClass);
2752
2759
  });
2753
2760
  });
2754
2761
  });
@@ -2764,10 +2771,11 @@ var NativeComponents = (function (exports) {
2764
2771
  };
2765
2772
 
2766
2773
  NDElement.prototype.animate = function(animationName) {
2767
- this.$element.classes.add(animationName);
2774
+ const el = this.$element;
2775
+ el.classes.add(animationName);
2768
2776
 
2769
- waitForVisualEnd(this.$element).then(() => {
2770
- this.$element.classes.remove(animationName);
2777
+ waitForVisualEnd(el).then(() => {
2778
+ el.classes.remove(animationName);
2771
2779
  });
2772
2780
 
2773
2781
  return this;
@@ -3050,10 +3058,12 @@ var NativeComponents = (function (exports) {
3050
3058
  "ContextMenu"
3051
3059
  ];
3052
3060
 
3061
+ const $sharedNdElement = new NDElement(null);
3053
3062
  const property = {
3054
3063
  configurable: true,
3055
3064
  get() {
3056
- return new NDElement(this);
3065
+ $sharedNdElement.$element = this;
3066
+ return $sharedNdElement;
3057
3067
  }
3058
3068
  };
3059
3069
 
@@ -395,7 +395,6 @@ var NativeDocument = (function (exports) {
395
395
 
396
396
  function NDElement(element) {
397
397
  this.$element = element;
398
- this.$observer = null;
399
398
  {
400
399
  PluginsManager.emit('NDElementCreated', element, this);
401
400
  }
@@ -413,7 +412,7 @@ var NativeDocument = (function (exports) {
413
412
  };
414
413
 
415
414
  NDElement.prototype.refSelf = function(target, name) {
416
- target[name] = this;
415
+ target[name] = new NDElement(this.$element);
417
416
  return this;
418
417
  };
419
418
 
@@ -434,23 +433,28 @@ var NativeDocument = (function (exports) {
434
433
  let element = this.$element;
435
434
  element.nd.unmountChildren();
436
435
  element.$ndProx = null;
437
- delete element.nd?.on?.prevent;
438
- delete element.nd?.on;
439
- delete element.nd;
436
+
437
+ $lifeCycleObservers.delete(element);
438
+
440
439
  element = null;
441
440
  return this;
442
441
  };
443
442
 
443
+ const $lifeCycleObservers = new WeakMap();
444
444
  NDElement.prototype.lifecycle = function(states) {
445
- this.$observer = this.$observer || DocumentObserver.watch(this.$element);
445
+ const el = this.$element;
446
+ if (!$lifeCycleObservers.has(el)) {
447
+ $lifeCycleObservers.set(el, DocumentObserver.watch(el));
448
+ }
449
+ const observer = $lifeCycleObservers.get(el);
446
450
 
447
451
  if(states.mounted) {
448
452
  this.$element.setAttribute('data--nd-mounted', '1');
449
- this.$observer.mounted(states.mounted);
453
+ observer.mounted(states.mounted);
450
454
  }
451
455
  if(states.unmounted) {
452
456
  this.$element.setAttribute('data--nd-unmounted', '1');
453
- this.$observer.unmounted(states.unmounted);
457
+ observer.unmounted(states.unmounted);
454
458
  }
455
459
  return this;
456
460
  };
@@ -2575,10 +2579,11 @@ var NativeDocument = (function (exports) {
2575
2579
 
2576
2580
  NDElement.prototype.transitionOut = function(transitionName) {
2577
2581
  const exitClass = transitionName + '-exit';
2582
+ const el = this.$element;
2578
2583
  this.beforeUnmount('transition-exit', async function() {
2579
- this.$element.classes.add(exitClass);
2580
- await waitForVisualEnd(this.$element);
2581
- this.$element.classes.remove(exitClass);
2584
+ el.classes.add(exitClass);
2585
+ await waitForVisualEnd(el);
2586
+ el.classes.remove(exitClass);
2582
2587
  });
2583
2588
  return this;
2584
2589
  };
@@ -2587,16 +2592,18 @@ var NativeDocument = (function (exports) {
2587
2592
  const startClass = transitionName + '-enter-from';
2588
2593
  const endClass = transitionName + '-enter-to';
2589
2594
 
2590
- this.$element.classes.add(startClass);
2595
+ const el = this.$element;
2596
+
2597
+ el.classes.add(startClass);
2591
2598
 
2592
2599
  this.mounted(() => {
2593
2600
  requestAnimationFrame(() => {
2594
2601
  requestAnimationFrame(() => {
2595
- this.$element.classes.remove(startClass);
2596
- this.$element.classes.add(endClass);
2602
+ el.classes.remove(startClass);
2603
+ el.classes.add(endClass);
2597
2604
 
2598
- waitForVisualEnd(this.$element).then(() => {
2599
- this.$element.classes.remove(endClass);
2605
+ waitForVisualEnd(el).then(() => {
2606
+ el.classes.remove(endClass);
2600
2607
  });
2601
2608
  });
2602
2609
  });
@@ -2612,10 +2619,11 @@ var NativeDocument = (function (exports) {
2612
2619
  };
2613
2620
 
2614
2621
  NDElement.prototype.animate = function(animationName) {
2615
- this.$element.classes.add(animationName);
2622
+ const el = this.$element;
2623
+ el.classes.add(animationName);
2616
2624
 
2617
- waitForVisualEnd(this.$element).then(() => {
2618
- this.$element.classes.remove(animationName);
2625
+ waitForVisualEnd(el).then(() => {
2626
+ el.classes.remove(animationName);
2619
2627
  });
2620
2628
 
2621
2629
  return this;
@@ -2908,10 +2916,12 @@ var NativeDocument = (function (exports) {
2908
2916
  "ContextMenu"
2909
2917
  ];
2910
2918
 
2919
+ const $sharedNdElement = new NDElement(null);
2911
2920
  const property = {
2912
2921
  configurable: true,
2913
2922
  get() {
2914
- return new NDElement(this);
2923
+ $sharedNdElement.$element = this;
2924
+ return $sharedNdElement;
2915
2925
  }
2916
2926
  };
2917
2927
 
@@ -6714,7 +6724,7 @@ var NativeDocument = (function (exports) {
6714
6724
  cleanContainer();
6715
6725
  const anchor = getNodeAnchorForLayout(nodeToInsert, path);
6716
6726
 
6717
- $currentLayout = layout(anchor);
6727
+ $currentLayout = ElementCreator.getChild(layout(anchor));
6718
6728
  $layoutCache.set(nodeToInsert, $currentLayout);
6719
6729
  container.appendChild($currentLayout);
6720
6730
  };
@@ -7014,6 +7024,17 @@ var NativeDocument = (function (exports) {
7014
7024
  return Router.get(name).back();
7015
7025
  };
7016
7026
 
7027
+ Router.redirectTo = function(pathOrRouteName, params = null, name = null) {
7028
+ let target = pathOrRouteName;
7029
+ const router = Router.get(name);
7030
+ const route = router.resolve({ name: pathOrRouteName, params });
7031
+ if(route) {
7032
+ target = { name: pathOrRouteName, params};
7033
+ }
7034
+ console.log(target);
7035
+ return router.push(target);
7036
+ };
7037
+
7017
7038
  function Link(options, children){
7018
7039
  const { to, href, ...attributes } = options;
7019
7040
  if(href) {