taggedjs 2.4.14 → 2.4.16

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 (48) hide show
  1. package/bundle.js +93 -188
  2. package/bundle.js.map +1 -1
  3. package/js/Clones.type.d.ts +0 -1
  4. package/js/Clones.type.js +1 -1
  5. package/js/Clones.type.js.map +1 -1
  6. package/js/Tag.class.js +52 -92
  7. package/js/Tag.class.js.map +1 -1
  8. package/js/TemplaterResult.class.d.ts +17 -16
  9. package/js/TemplaterResult.class.js.map +1 -1
  10. package/js/checkDestroyPrevious.function.js +5 -11
  11. package/js/checkDestroyPrevious.function.js.map +1 -1
  12. package/js/interpolateTemplate.js +5 -0
  13. package/js/interpolateTemplate.js.map +1 -1
  14. package/js/processSubjectComponent.function.js +3 -0
  15. package/js/processSubjectComponent.function.js.map +1 -1
  16. package/js/processTag.function.js +1 -1
  17. package/js/processTag.function.js.map +1 -1
  18. package/js/processTagArray.d.ts +1 -2
  19. package/js/processTagArray.js +12 -32
  20. package/js/processTagArray.js.map +1 -1
  21. package/js/processTagResult.function.d.ts +3 -2
  22. package/js/processTagResult.function.js +5 -3
  23. package/js/processTagResult.function.js.map +1 -1
  24. package/js/updateExistingTagComponent.function.js +1 -5
  25. package/js/updateExistingTagComponent.function.js.map +1 -1
  26. package/js/updateExistingValue.function.js +4 -19
  27. package/js/updateExistingValue.function.js.map +1 -1
  28. package/package.json +1 -1
  29. package/js/Subject.d.ts +0 -17
  30. package/js/Subject.js +0 -47
  31. package/js/Subject.js.map +0 -1
  32. package/js/ValueSubject.d.ts +0 -8
  33. package/js/ValueSubject.js +0 -15
  34. package/js/ValueSubject.js.map +0 -1
  35. package/js/bindSubjectCallback.function 9.27.33/342/200/257AM.js" +0 -32
  36. package/js/bindSubjectCallback.function.d 9.27.33/342/200/257AM.ts" +0 -8
  37. package/js/redrawTag.function.d.ts +0 -5
  38. package/js/redrawTag.function.js +0 -18
  39. package/js/redrawTag.function.js.map +0 -1
  40. package/js/templater.utils.d.ts +0 -37
  41. package/js/templater.utils.js +0 -118
  42. package/js/templater.utils.js.map +0 -1
  43. package/js/updateExistingTag.function.d.ts +0 -4
  44. package/js/updateExistingTag.function.js +0 -24
  45. package/js/updateExistingTag.function.js.map +0 -1
  46. /package/js/{Errors.d.ts → errors.d.ts} +0 -0
  47. /package/js/{Errors.js → errors.js} +0 -0
  48. /package/js/{Errors.js.map → errors.js.map} +0 -0
package/bundle.js CHANGED
@@ -1,20 +1,5 @@
1
1
  /******/ var __webpack_modules__ = ({
2
2
 
3
- /***/ "./ts/Clones.type.ts":
4
- /*!***************************!*\
5
- !*** ./ts/Clones.type.ts ***!
6
- \***************************/
7
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
-
9
- __webpack_require__.r(__webpack_exports__);
10
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11
- /* harmony export */ isRemoveTemplates: () => (/* binding */ isRemoveTemplates)
12
- /* harmony export */ });
13
- const isRemoveTemplates = true;
14
-
15
-
16
- /***/ }),
17
-
18
3
  /***/ "./ts/ElementTargetEvent.interface.ts":
19
4
  /*!********************************************!*\
20
5
  !*** ./ts/ElementTargetEvent.interface.ts ***!
@@ -48,11 +33,7 @@ __webpack_require__.r(__webpack_exports__);
48
33
  /* harmony import */ var _processNewValue_function__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./processNewValue.function */ "./ts/processNewValue.function.ts");
49
34
  /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./isInstance */ "./ts/isInstance.ts");
50
35
  /* harmony import */ var _isLikeTags_function__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./isLikeTags.function */ "./ts/isLikeTags.function.ts");
51
- /* harmony import */ var _Clones_type__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Clones.type */ "./ts/Clones.type.ts");
52
- /* harmony import */ var _checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./checkDestroyPrevious.function */ "./ts/checkDestroyPrevious.function.ts");
53
- /* harmony import */ var _insertAfter_function__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./insertAfter.function */ "./ts/insertAfter.function.ts");
54
-
55
-
36
+ /* harmony import */ var _checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./checkDestroyPrevious.function */ "./ts/checkDestroyPrevious.function.ts");
56
37
 
57
38
 
58
39
 
@@ -105,15 +86,15 @@ class Tag {
105
86
  const subject = tagSupport.subject;
106
87
  // put back down the template tag
107
88
  const insertBefore = global.insertBefore;
108
- if (_Clones_type__WEBPACK_IMPORTED_MODULE_8__.isRemoveTemplates) {
109
- const placeholder = global.placeholderElm;
89
+ if (insertBefore.nodeName === 'TEMPLATE') {
90
+ const placeholder = global.placeholder;
110
91
  if (placeholder && !('arrayValue' in this.memory)) {
111
92
  if (!options.byParent) {
112
- (0,_checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_9__.restoreTagMarker)(this, insertBefore);
93
+ (0,_checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_8__.restoreTagMarker)(this, insertBefore);
113
94
  }
114
95
  }
115
96
  }
116
- delete global.placeholderElm;
97
+ delete global.placeholder;
117
98
  // the isComponent check maybe able to be removed
118
99
  const isComponent = tagSupport ? true : false;
119
100
  if (isComponent) {
@@ -289,17 +270,20 @@ class Tag {
289
270
  const subject = this.tagSupport.subject;
290
271
  const thisTemplater = this.tagSupport.templater;
291
272
  const global = thisTemplater.global;
292
- if (_Clones_type__WEBPACK_IMPORTED_MODULE_8__.isRemoveTemplates) {
293
- const placeholderElm = global.placeholderElm;
294
- if (placeholderElm) {
295
- const parentNode = placeholderElm.parentNode;
296
- parentNode.insertBefore(insertBefore, placeholderElm);
297
- // ??? - removed as we don't steal clones anymore
298
- // this.clones.push( placeholderElm ) // put back on chopping block
299
- delete global.placeholderElm;
273
+ global.insertBefore = insertBefore;
274
+ if (!global.placeholder) {
275
+ if (insertBefore.nodeName !== 'TEMPLATE') {
276
+ throw new Error(' no template at insertBefore');
277
+ global.placeholder = insertBefore;
278
+ }
279
+ else {
280
+ setTagPlaceholder(global);
300
281
  }
301
282
  }
302
- const trueInsertBefore = insertBefore;
283
+ if (!global.placeholder?.parentNode) {
284
+ throw new Error('????');
285
+ }
286
+ const placeholderElm = global.placeholder;
303
287
  global.oldest = this;
304
288
  global.newest = this;
305
289
  subject.tag = this;
@@ -312,7 +296,7 @@ class Tag {
312
296
  // const context = this.tagSupport.memory.context // this.update()
313
297
  const context = this.update();
314
298
  const template = this.getTemplate();
315
- if (!trueInsertBefore.parentNode) {
299
+ if (!placeholderElm.parentNode) {
316
300
  throw new Error('no parent before building tag');
317
301
  }
318
302
  const elementContainer = document.createElement('div');
@@ -325,60 +309,45 @@ class Tag {
325
309
  forceElement: options.forceElement,
326
310
  counts: options.counts
327
311
  });
328
- if (!trueInsertBefore.parentNode) {
329
- throw new Error('no parent building tag');
312
+ if (!placeholderElm.parentNode) {
313
+ throw new Error('no parent after building tag');
330
314
  }
331
- afterInterpolateElement(elementContainer, trueInsertBefore, // insertBefore (will be removed)
332
- this, // ownerTag
315
+ afterInterpolateElement(elementContainer, placeholderElm, this, // ownerTag
333
316
  context, options);
317
+ if (!global.placeholder?.parentNode) {
318
+ throw new Error('???? - 2');
319
+ }
334
320
  // Any tag components that were found should be processed AFTER the owner processes its elements. Avoid double processing of elements attributes like (oninit)=${}
335
321
  let isForceElement = options.forceElement;
336
322
  tagComponents.forEach(tagComponent => {
337
323
  const tagSupport = tagComponent.ownerTag.tagSupport;
338
324
  const tagGlobal = tagSupport.templater.global;
339
- const placeholderElm = tagGlobal.placeholderElm; // global.placeholderElm
325
+ const placeholderElm = tagGlobal.placeholder; // global.placeholderElm
340
326
  if (!placeholderElm && !insertBefore.parentNode) {
341
327
  throw new Error('no parent building tag components');
342
328
  }
343
- const before = tagComponent.insertBefore; // insertBefore (will be removed)
344
- (0,_interpolateTemplate__WEBPACK_IMPORTED_MODULE_3__.subscribeToTemplate)(before, // tagComponent.insertBefore,
345
- tagComponent.subject, tagComponent.ownerTag, options.counts, { isForceElement });
346
- const clones = afterInterpolateElement(elementContainer, before, // (will be removed)
347
- tagComponent.ownerTag, // this, // ownerTag
348
- context, options);
349
- if (placeholderElm && !placeholderElm?.parentNode) {
350
- const clone = clones[this.clones.length - 1];
351
- if (clone) {
352
- (0,_checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_9__.restoreTagMarker)(tagComponent.ownerTag, clone);
353
- }
329
+ if (!global.placeholder?.parentNode) {
330
+ throw new Error('???? - 3');
354
331
  }
355
- if (placeholderElm) {
356
- if (placeholderElm.parentNode) {
357
- if (!global.placeholderElm) {
358
- global.placeholderElm = placeholderElm;
359
- }
360
- }
361
- if (this.clones.length) {
362
- if (insertBefore.parentNode) {
363
- global.placeholderElm = insertBefore.previousSibling;
364
- const parentNode = insertBefore.parentNode;
365
- parentNode.removeChild(insertBefore);
366
- }
367
- }
332
+ (0,_interpolateTemplate__WEBPACK_IMPORTED_MODULE_3__.subscribeToTemplate)(tagComponent.insertBefore, tagComponent.subject, tagComponent.ownerTag, options.counts, { isForceElement });
333
+ if (!global.placeholder?.parentNode) {
334
+ throw new Error('???? - 4');
368
335
  }
369
- });
370
- if (!global.placeholderElm) {
371
- // const clone = getLastCloneFromTags(this)
372
- // const clone = (insertBefore as Element).previousElementSibling as Element
373
- const clone = insertBefore.previousSibling;
374
- if (clone) {
375
- const parentNode = insertBefore.parentNode;
376
- global.placeholderElm = clone;
377
- parentNode.removeChild(insertBefore);
336
+ afterInterpolateElement(elementContainer, tagComponent.insertBefore, tagComponent.ownerTag, // this, // ownerTag
337
+ context, options);
338
+ if (!global.placeholder?.parentNode) {
339
+ throw new Error('???? - 5');
378
340
  }
379
- }
341
+ });
380
342
  }
381
343
  }
344
+ function setTagPlaceholder(global) {
345
+ const insertBefore = global.insertBefore;
346
+ const placeholder = global.placeholder = document.createTextNode('');
347
+ const parentNode = insertBefore.parentNode;
348
+ parentNode.insertBefore(placeholder, insertBefore);
349
+ parentNode.removeChild(insertBefore);
350
+ }
382
351
  function afterInterpolateElement(container, insertBefore, tag,
383
352
  // preClones: Clones,
384
353
  context, options) {
@@ -386,37 +355,8 @@ context, options) {
386
355
  if (!clones.length) {
387
356
  return clones;
388
357
  }
389
- const ownerSupport = tag.tagSupport;
390
- const ownerGlobal = ownerSupport.templater.global;
391
- const hadBefore = _Clones_type__WEBPACK_IMPORTED_MODULE_8__.isRemoveTemplates && ownerGlobal.placeholderElm;
392
- const parentNode = hadBefore ? ownerGlobal.placeholderElm?.parentNode : insertBefore.parentNode;
393
- // we could now be processing same tag but more after components being rendered
394
- if (hadBefore) {
395
- // 0 put the template back down
396
- (0,_insertAfter_function__WEBPACK_IMPORTED_MODULE_10__.insertAfter)(insertBefore, hadBefore);
397
- // ??? - removed as need for arrays
398
- delete ownerGlobal.placeholderElm;
399
- }
400
358
  clones.forEach(clone => (0,_interpolateTemplate__WEBPACK_IMPORTED_MODULE_3__.afterElmBuild)(clone, options, context, tag));
401
- let hasPopClone;
402
- if (_Clones_type__WEBPACK_IMPORTED_MODULE_8__.isRemoveTemplates) {
403
- const clone = insertBefore.previousSibling; // clones[clones.length - 1]
404
- if (clone) {
405
- const isTemplate = clone.tagName === 'TEMPLATE' && clone.hasAttribute('interpolate');
406
- if (!isTemplate) {
407
- hasPopClone = ownerGlobal.placeholderElm = clone; // insertBefore
408
- }
409
- }
410
- }
411
- if (clones.find(x => x === insertBefore)) {
412
- throw new Error('adding marker to owner in tag class');
413
- }
414
359
  tag.clones.push(...clones);
415
- if (_Clones_type__WEBPACK_IMPORTED_MODULE_8__.isRemoveTemplates) {
416
- if (hasPopClone) { // || hadBefore
417
- parentNode.removeChild(insertBefore); // belongs to another tag
418
- }
419
- }
420
360
  return clones;
421
361
  }
422
362
  function getChildTagsToDestroy(childTags, allTags = []) {
@@ -437,15 +377,9 @@ function updateContextItem(context, variableName, value) {
437
377
  const tag = subject.tag;
438
378
  if (tag) {
439
379
  const oldTemp = tag.tagSupport.templater;
440
- const oldWrap = oldTemp.wrapper; // tag versus component
441
- if (value.global !== oldTemp.global) {
442
- if (oldWrap && (0,_isInstance__WEBPACK_IMPORTED_MODULE_6__.isTagComponent)(value)) {
443
- const oldValueFn = oldWrap.original;
444
- const newValueFn = value.wrapper?.original;
445
- const fnMatched = oldValueFn === newValueFn;
446
- if (fnMatched) {
447
- value.global = oldTemp.global;
448
- }
380
+ if (value && value.global !== oldTemp.global) {
381
+ if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_6__.isTagComponent)(value)) {
382
+ shareTemplaterGlobal(oldTemp, value);
449
383
  }
450
384
  }
451
385
  }
@@ -456,6 +390,15 @@ function updateContextItem(context, variableName, value) {
456
390
  subject.set(value); // listeners will evaluate updated values to possibly update display(s)
457
391
  return;
458
392
  }
393
+ function shareTemplaterGlobal(oldTemp, value) {
394
+ const oldWrap = oldTemp.wrapper; // tag versus component
395
+ const oldValueFn = oldWrap.original;
396
+ const newValueFn = value.wrapper?.original;
397
+ const fnMatched = oldValueFn === newValueFn;
398
+ if (fnMatched) {
399
+ value.global = oldTemp.global;
400
+ }
401
+ }
459
402
 
460
403
 
461
404
  /***/ }),
@@ -779,9 +722,7 @@ __webpack_require__.r(__webpack_exports__);
779
722
  /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./isInstance */ "./ts/isInstance.ts");
780
723
  /* harmony import */ var _isLikeTags_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./isLikeTags.function */ "./ts/isLikeTags.function.ts");
781
724
  /* harmony import */ var _destroyTag_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./destroyTag.function */ "./ts/destroyTag.function.ts");
782
- /* harmony import */ var _Clones_type__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Clones.type */ "./ts/Clones.type.ts");
783
- /* harmony import */ var _insertAfter_function__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./insertAfter.function */ "./ts/insertAfter.function.ts");
784
-
725
+ /* harmony import */ var _insertAfter_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./insertAfter.function */ "./ts/insertAfter.function.ts");
785
726
 
786
727
 
787
728
 
@@ -792,10 +733,10 @@ newValue, insertBefore) {
792
733
  const wasArray = arraySubject.lastArray;
793
734
  // no longer an array
794
735
  if (wasArray && !(0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isTagArray)(newValue)) {
795
- const placeholderElm = arraySubject.placeholderElm;
736
+ const placeholderElm = arraySubject.placeholder;
796
737
  delete arraySubject.lastArray;
797
- delete arraySubject.placeholderElm;
798
- (0,_insertAfter_function__WEBPACK_IMPORTED_MODULE_4__.insertAfter)(insertBefore, placeholderElm);
738
+ delete arraySubject.placeholder;
739
+ (0,_insertAfter_function__WEBPACK_IMPORTED_MODULE_3__.insertAfter)(insertBefore, placeholderElm);
799
740
  wasArray.forEach(({ tag }) => destroyArrayTag(tag, { added: 0, removed: 0 }));
800
741
  return 'array';
801
742
  }
@@ -810,9 +751,7 @@ newValue, insertBefore) {
810
751
  // its a different tag now
811
752
  if (!(0,_isLikeTags_function__WEBPACK_IMPORTED_MODULE_1__.isLikeTags)(newTag, existingTag)) {
812
753
  // put template back down
813
- if (_Clones_type__WEBPACK_IMPORTED_MODULE_3__.isRemoveTemplates) {
814
- restoreTagMarker(existingTag, insertBefore);
815
- }
754
+ restoreTagMarker(existingTag, insertBefore);
816
755
  (0,_destroyTag_function__WEBPACK_IMPORTED_MODULE_2__.destroyTagMemory)(existingTag, tagSubject);
817
756
  return 2;
818
757
  }
@@ -823,9 +762,7 @@ newValue, insertBefore) {
823
762
  return false; // its still a tag component
824
763
  }
825
764
  // put template back down
826
- if (_Clones_type__WEBPACK_IMPORTED_MODULE_3__.isRemoveTemplates) {
827
- restoreTagMarker(existingTag, insertBefore);
828
- }
765
+ restoreTagMarker(existingTag, insertBefore);
829
766
  // destroy old component, value is not a component
830
767
  (0,_destroyTag_function__WEBPACK_IMPORTED_MODULE_2__.destroyTagMemory)(existingTag, tagSubject);
831
768
  return 'different-tag';
@@ -858,10 +795,9 @@ subject) {
858
795
  }
859
796
  function restoreTagMarker(existingTag, insertBefore) {
860
797
  const global = existingTag.tagSupport.templater.global;
861
- const placeholderElm = global.placeholderElm;
798
+ const placeholderElm = global.placeholder;
862
799
  if (placeholderElm) {
863
- (0,_insertAfter_function__WEBPACK_IMPORTED_MODULE_4__.insertAfter)(insertBefore, placeholderElm);
864
- // delete global.placeholderElm
800
+ (0,_insertAfter_function__WEBPACK_IMPORTED_MODULE_3__.insertAfter)(insertBefore, placeholderElm);
865
801
  }
866
802
  }
867
803
 
@@ -1556,6 +1492,11 @@ function subscribeToTemplate(insertBefore, subject, ownerTag, counts, // used fo
1556
1492
  (0,_updateExistingValue_function__WEBPACK_IMPORTED_MODULE_5__.updateExistingValue)(subject, value, ownerTag, insertBefore);
1557
1493
  return;
1558
1494
  }
1495
+ if (!insertBefore.parentNode) {
1496
+ throw new Error('no insert before parent node - 3');
1497
+ }
1498
+ const global = ownerTag.tagSupport.templater.global;
1499
+ const pre = global.placeholder?.parentNode;
1559
1500
  (0,_processSubjectValue_function__WEBPACK_IMPORTED_MODULE_2__.processSubjectValue)(value, subject, insertBefore, ownerTag, {
1560
1501
  counts: { ...counts },
1561
1502
  forceElement: isForceElement,
@@ -2004,6 +1945,9 @@ function processSubjectComponent(templater, subject, insertBefore, ownerTag, opt
2004
1945
  }
2005
1946
  templater.tagSupport = new _TagSupport_class__WEBPACK_IMPORTED_MODULE_3__.TagSupport(ownerTag.tagSupport, templater, subject);
2006
1947
  // templater.oldest = subject.tag?.tagSupport.oldest || templater.oldest
1948
+ if (insertBefore.nodeName != 'TEMPLATE') {
1949
+ throw new Error('9');
1950
+ }
2007
1951
  templater.global.insertBefore = insertBefore;
2008
1952
  let retag = subject.tag;
2009
1953
  const providers = _setUse_function__WEBPACK_IMPORTED_MODULE_1__.setUse.memory.providerConfig;
@@ -2135,7 +2079,7 @@ insertBefore, ownerTag) {
2135
2079
  }
2136
2080
  tag.ownerTag = ownerTag;
2137
2081
  if (insertBefore.tagName !== 'TEMPLATE') {
2138
- throw new Error(`;;;; - ${insertBefore.nodeName}`);
2082
+ throw new Error(`processTag.function.ts - insertBefore is not TEMPLATE ${insertBefore.tagName}`);
2139
2083
  }
2140
2084
  tag.buildBeforeElement(insertBefore, {
2141
2085
  counts: { added: 0, removed: 0 },
@@ -2192,8 +2136,6 @@ __webpack_require__.r(__webpack_exports__);
2192
2136
  /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./errors */ "./ts/errors.ts");
2193
2137
  /* harmony import */ var _checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./checkDestroyPrevious.function */ "./ts/checkDestroyPrevious.function.ts");
2194
2138
  /* harmony import */ var _processTag_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./processTag.function */ "./ts/processTag.function.ts");
2195
- /* harmony import */ var _insertAfter_function__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./insertAfter.function */ "./ts/insertAfter.function.ts");
2196
-
2197
2139
 
2198
2140
 
2199
2141
 
@@ -2203,17 +2145,10 @@ insertBefore, // <template end interpolate />
2203
2145
  ownerTag, options) {
2204
2146
  const clones = ownerTag.clones; // []
2205
2147
  let lastArray = subject.lastArray = subject.lastArray || [];
2206
- if (subject.placeholderElm) {
2207
- const parentPlaceholder = subject.parentAsPlaceholder;
2208
- if (parentPlaceholder) {
2209
- parentPlaceholder.appendChild(insertBefore);
2210
- delete subject.placeholderElm;
2211
- }
2212
- else {
2213
- (0,_insertAfter_function__WEBPACK_IMPORTED_MODULE_4__.insertAfter)(insertBefore, subject.placeholderElm);
2214
- }
2215
- delete subject.placeholderElm;
2148
+ if (!subject.placeholder) {
2149
+ setPlaceholderElm(insertBefore, subject);
2216
2150
  }
2151
+ const runtimeInsertBefore = subject.placeholder; // || insertBefore
2217
2152
  let removed = 0;
2218
2153
  /** 🗑️ remove previous items first */
2219
2154
  lastArray = subject.lastArray = subject.lastArray.filter((item, index) => {
@@ -2235,8 +2170,6 @@ ownerTag, options) {
2235
2170
  }
2236
2171
  return true;
2237
2172
  });
2238
- // const masterBefore = template || (template as any).clone
2239
- const before = insertBefore; // || (subject.value as any).insertBefore || (insertBefore as any).clone
2240
2173
  value.forEach((subTag, index) => {
2241
2174
  const previous = lastArray[index];
2242
2175
  const previousSupport = previous?.tag.tagSupport;
@@ -2271,33 +2204,23 @@ ownerTag, options) {
2271
2204
  return [];
2272
2205
  }
2273
2206
  // TODO: should not get here?
2274
- processAddTagArrayItem(before, subTag, index, options, lastArray);
2207
+ processAddTagArrayItem(runtimeInsertBefore, subTag, index, options, lastArray);
2275
2208
  throw new Error('item should be back');
2276
2209
  // return [] // removed: item should have been previously deleted and will be added back
2277
2210
  }
2278
- processAddTagArrayItem(before, subTag, index, options, lastArray);
2211
+ processAddTagArrayItem(runtimeInsertBefore, subTag, index, options, lastArray);
2279
2212
  ownerTag.childTags.push(subTag);
2280
2213
  });
2281
- if (value.length) {
2282
- const lastClone = insertBefore.previousSibling;
2283
- setPlaceholderElm(lastClone, insertBefore, subject);
2284
- }
2285
- else {
2286
- const placeholderElm = insertBefore.previousSibling;
2287
- if (placeholderElm) {
2288
- setPlaceholderElm(placeholderElm, insertBefore, subject);
2289
- }
2290
- else {
2291
- const parentNode = insertBefore.parentNode;
2292
- setPlaceholderElm(parentNode, insertBefore, subject);
2293
- subject.parentAsPlaceholder = parentNode;
2294
- }
2295
- }
2296
2214
  return clones;
2297
2215
  }
2298
- function setPlaceholderElm(lastClone, insertBefore, subject) {
2299
- subject.placeholderElm = lastClone;
2216
+ function setPlaceholderElm(insertBefore, subject) {
2217
+ if (insertBefore.nodeName !== 'TEMPLATE') {
2218
+ subject.placeholder = insertBefore;
2219
+ return;
2220
+ }
2221
+ const placeholder = subject.placeholder = document.createTextNode('');
2300
2222
  const parentNode = insertBefore.parentNode;
2223
+ parentNode.insertBefore(placeholder, insertBefore);
2301
2224
  parentNode.removeChild(insertBefore);
2302
2225
  }
2303
2226
  function processAddTagArrayItem(before, subTag, index, options, lastArray) {
@@ -2348,7 +2271,7 @@ function processTagResult(tag, subject, // used for recording past and current v
2348
2271
  insertBefore, // <template end interpolate />
2349
2272
  { counts, forceElement, }) {
2350
2273
  if (!insertBefore.parentNode) {
2351
- throw new Error('before here processTagResult');
2274
+ throw new Error(`before here processTagResult ${insertBefore.nodeName}`);
2352
2275
  }
2353
2276
  // *if appears we already have seen
2354
2277
  const subjectTag = subject;
@@ -2366,9 +2289,11 @@ insertBefore, // <template end interpolate />
2366
2289
  */
2367
2290
  return processTagResultUpdate(tag, subjectTag, previousTag);
2368
2291
  }
2369
- if (insertBefore.nodeName !== 'TEMPLATE') {
2370
- throw new Error(';;;;');
2292
+ /*
2293
+ if(insertBefore.nodeName !== 'TEMPLATE') {
2294
+ throw new Error(`processTagResult.function.ts insertBefore is not template ${insertBefore.nodeName}`)
2371
2295
  }
2296
+ */
2372
2297
  tag.buildBeforeElement(insertBefore, {
2373
2298
  counts,
2374
2299
  forceElement,
@@ -3555,17 +3480,13 @@ function updateExistingTagComponent(ownerTag, templater, subject, insertBefore)
3555
3480
  const oldTagSupport = existingTag.tagSupport;
3556
3481
  const oldGlobal = oldTagSupport.templater.global;
3557
3482
  const globalInsert = oldGlobal.insertBefore;
3558
- const oldInsertBefore = globalInsert?.parentNode ? globalInsert : insertBefore;
3559
3483
  // const placeholderElm = ownerTag.tagSupport.templater.global.placeholderElm
3560
- const placeholderElm = oldGlobal.placeholderElm;
3484
+ const placeholderElm = oldGlobal.placeholder;
3561
3485
  if (placeholderElm) {
3562
3486
  if (!placeholderElm.parentNode) {
3563
3487
  throw new Error('stop here no subject parent node update existing tag');
3564
3488
  }
3565
3489
  }
3566
- else if (!oldInsertBefore.parentNode) {
3567
- //throw new Error('stop here no parent node update existing tag')
3568
- }
3569
3490
  if (!isSameTag) {
3570
3491
  (0,_destroyTag_function__WEBPACK_IMPORTED_MODULE_2__.destroyTagMemory)(oldTagSupport.templater.global.oldest, subject);
3571
3492
  return (0,_processSubjectComponent_function__WEBPACK_IMPORTED_MODULE_1__.processSubjectComponent)(templater, subject,
@@ -3713,8 +3634,6 @@ __webpack_require__.r(__webpack_exports__);
3713
3634
  /* harmony import */ var _isLikeTags_function__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./isLikeTags.function */ "./ts/isLikeTags.function.ts");
3714
3635
  /* harmony import */ var _bindSubjectCallback_function__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./bindSubjectCallback.function */ "./ts/bindSubjectCallback.function.ts");
3715
3636
  /* harmony import */ var _processTag_function__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./processTag.function */ "./ts/processTag.function.ts");
3716
- /* harmony import */ var _insertAfter_function__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./insertAfter.function */ "./ts/insertAfter.function.ts");
3717
-
3718
3637
 
3719
3638
 
3720
3639
 
@@ -3728,37 +3647,24 @@ __webpack_require__.r(__webpack_exports__);
3728
3647
  function updateExistingValue(subject, value, ownerTag, insertBefore) {
3729
3648
  const subjectTag = subject;
3730
3649
  const isComponent = (0,_isInstance__WEBPACK_IMPORTED_MODULE_1__.isTagComponent)(value);
3731
- // const global = subjectTag.tag?.tagSupport.templater.global
3732
- // const placeholderElm = global?.placeholderElm || global?.insertBefore || (subject as DisplaySubject).insertBefore
3733
- // const oldInsertBefore = placeholderElm || (subject as DisplaySubject).clone
3734
- const destroyType = (0,_checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_5__.checkDestroyPrevious)(subject, value, insertBefore);
3650
+ (0,_checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_5__.checkDestroyPrevious)(subject, value, insertBefore);
3735
3651
  // handle already seen tag components
3736
3652
  if (isComponent) {
3737
3653
  const templater = value;
3738
3654
  // When was something before component
3739
3655
  if (!subjectTag.tag) {
3740
- const tag = (0,_processSubjectComponent_function__WEBPACK_IMPORTED_MODULE_6__.processSubjectComponent)(templater, subjectTag, insertBefore, // oldInsertBefore as InsertBefore,
3656
+ (0,_processSubjectComponent_function__WEBPACK_IMPORTED_MODULE_6__.processSubjectComponent)(templater, subjectTag, insertBefore, // oldInsertBefore as InsertBefore,
3741
3657
  ownerTag, {
3742
3658
  forceElement: true,
3743
3659
  counts: { added: 0, removed: 0 },
3744
3660
  });
3745
3661
  return subjectTag;
3746
3662
  }
3747
- // ??? - new put back down template tag before redraw
3748
- const placeholderElm = subjectTag.tag.tagSupport.templater.global.placeholderElm;
3749
- if (placeholderElm) {
3750
- (0,_insertAfter_function__WEBPACK_IMPORTED_MODULE_10__.insertAfter)(insertBefore, placeholderElm);
3751
- delete subjectTag.tag.tagSupport.templater.global.placeholderElm;
3752
- }
3753
3663
  templater.tagSupport = new _TagSupport_class__WEBPACK_IMPORTED_MODULE_0__.TagSupport(
3754
3664
  // subjectTag.tag.tagSupport.ownerTagSupport,
3755
3665
  ownerTag.tagSupport, templater, subjectTag);
3756
- const tag = (0,_updateExistingTagComponent_function__WEBPACK_IMPORTED_MODULE_3__.updateExistingTagComponent)(ownerTag, templater, // latest value
3666
+ (0,_updateExistingTagComponent_function__WEBPACK_IMPORTED_MODULE_3__.updateExistingTagComponent)(ownerTag, templater, // latest value
3757
3667
  subjectTag, insertBefore);
3758
- if (insertBefore.parentNode) {
3759
- tag.tagSupport.templater.global.placeholderElm = insertBefore.previousSibling;
3760
- insertBefore.parentNode.removeChild(insertBefore);
3761
- }
3762
3668
  return subjectTag;
3763
3669
  }
3764
3670
  // was component but no longer
@@ -3784,7 +3690,7 @@ function updateExistingValue(subject, value, ownerTag, insertBefore) {
3784
3690
  return subject;
3785
3691
  }
3786
3692
  if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_1__.isTagInstance)(value)) {
3787
- if (insertBefore.tagName !== 'TEMPLATE') {
3693
+ if (insertBefore.nodeName !== 'TEMPLATE') {
3788
3694
  throw new Error(`expected template - ${insertBefore.nodeName}`);
3789
3695
  }
3790
3696
  (0,_processTag_function__WEBPACK_IMPORTED_MODULE_9__.processTag)(value, subjectTag, insertBefore, ownerTag);
@@ -3816,7 +3722,6 @@ function handleStillTag(existingTag, subject, value, ownerTag) {
3816
3722
  if (isSameTag || isSameTag2) {
3817
3723
  const subjectTag = subject;
3818
3724
  const global = existingTag.tagSupport.templater.global;
3819
- delete global.placeholderElm;
3820
3725
  const insertBefore = global.insertBefore;
3821
3726
  return (0,_processTag_function__WEBPACK_IMPORTED_MODULE_9__.processTag)(value, subjectTag, insertBefore, ownerTag);
3822
3727
  }