targetj 1.0.254 → 1.0.255

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.
package/build/$Dom.js CHANGED
@@ -133,10 +133,15 @@ var $Dom = /*#__PURE__*/function () {
133
133
  }
134
134
  return slot;
135
135
  }
136
+ }, {
137
+ key: "isManagedChildNode",
138
+ value: function isManagedChildNode(node) {
139
+ return (node === null || node === void 0 ? void 0 : node.nodeType) === 1 && node.getAttribute("tgjs") === "true";
140
+ }
136
141
  }, {
137
142
  key: "enableSlotMode",
138
143
  value: function enableSlotMode() {
139
- var _this$element4;
144
+ var _this = this;
140
145
  if (this.slotModeEnabled) {
141
146
  return;
142
147
  }
@@ -144,32 +149,24 @@ var $Dom = /*#__PURE__*/function () {
144
149
  this.slotModeEnabled = true;
145
150
  return;
146
151
  }
147
- var existingSlot = this.findContentSlot();
148
- if (existingSlot) {
149
- if (this.element.firstChild !== existingSlot) {
150
- this.element.insertBefore(existingSlot, this.element.firstChild);
152
+ var slot = this.findContentSlot();
153
+ if (!slot) {
154
+ var existingNodes = Array.from(this.element.childNodes);
155
+ slot = document.createElement("div");
156
+ slot.setAttribute("data-tj-slot", "content");
157
+ this.element.insertBefore(slot, this.element.firstChild);
158
+ for (var _i = 0, _existingNodes = existingNodes; _i < _existingNodes.length; _i++) {
159
+ var node = _existingNodes[_i];
160
+ if (!this.isManagedChildNode(node)) {
161
+ slot.appendChild(node);
162
+ }
151
163
  }
152
- this.contentSlot = existingSlot;
153
- this.slotModeEnabled = true;
154
- this.hasRealChildren = Array.from(this.element.childNodes).some(function (node) {
155
- return node !== existingSlot;
156
- });
157
- return;
158
- }
159
- if (!((_this$element4 = this.element) !== null && _this$element4 !== void 0 && _this$element4.firstChild)) {
160
- this.slotModeEnabled = true;
161
- return;
162
- }
163
- var existingNodes = Array.from(this.element.childNodes);
164
- var slot = document.createElement("div");
165
- slot.setAttribute("data-tj-slot", "content");
166
- this.element.insertBefore(slot, this.element.firstChild);
167
- for (var _i = 0, _existingNodes = existingNodes; _i < _existingNodes.length; _i++) {
168
- var node = _existingNodes[_i];
169
- slot.appendChild(node);
170
164
  }
171
165
  this.contentSlot = slot;
172
166
  this.slotModeEnabled = true;
167
+ this.hasRealChildren = Array.from(this.element.children).some(function (child) {
168
+ return child !== slot && _this.isManagedChildNode(child);
169
+ });
173
170
  }
174
171
  }, {
175
172
  key: "ensureSlotMode",
@@ -201,8 +198,8 @@ var $Dom = /*#__PURE__*/function () {
201
198
  }, {
202
199
  key: "getTagName",
203
200
  value: function getTagName() {
204
- var _this$element5;
205
- return (_this$element5 = this.element) === null || _this$element5 === void 0 || (_this$element5 = _this$element5.tagName) === null || _this$element5 === void 0 ? void 0 : _this$element5.toLowerCase();
201
+ var _this$element4;
202
+ return (_this$element4 = this.element) === null || _this$element4 === void 0 || (_this$element4 = _this$element4.tagName) === null || _this$element4 === void 0 ? void 0 : _this$element4.toLowerCase();
206
203
  }
207
204
  }, {
208
205
  key: "setSelector",
@@ -291,9 +288,9 @@ var $Dom = /*#__PURE__*/function () {
291
288
  }, {
292
289
  key: "setStyleByMap",
293
290
  value: function setStyleByMap(attrMap) {
294
- var _this = this;
291
+ var _this2 = this;
295
292
  Object.keys(attrMap).forEach(function (key) {
296
- _this.style(key, attrMap[key]);
293
+ _this2.style(key, attrMap[key]);
297
294
  });
298
295
  }
299
296
  }, {
@@ -578,14 +575,14 @@ var $Dom = /*#__PURE__*/function () {
578
575
  }, {
579
576
  key: "getScrollTop",
580
577
  value: function getScrollTop() {
581
- var _this$element$scrollT, _this$element6;
582
- return (_this$element$scrollT = (_this$element6 = this.element) === null || _this$element6 === void 0 ? void 0 : _this$element6.scrollTop) !== null && _this$element$scrollT !== void 0 ? _this$element$scrollT : 0;
578
+ var _this$element$scrollT, _this$element5;
579
+ return (_this$element$scrollT = (_this$element5 = this.element) === null || _this$element5 === void 0 ? void 0 : _this$element5.scrollTop) !== null && _this$element$scrollT !== void 0 ? _this$element$scrollT : 0;
583
580
  }
584
581
  }, {
585
582
  key: "getScrollLeft",
586
583
  value: function getScrollLeft() {
587
- var _this$element$scrollL, _this$element7;
588
- return (_this$element$scrollL = (_this$element7 = this.element) === null || _this$element7 === void 0 ? void 0 : _this$element7.scrollLeft) !== null && _this$element$scrollL !== void 0 ? _this$element$scrollL : 0;
584
+ var _this$element$scrollL, _this$element6;
585
+ return (_this$element$scrollL = (_this$element6 = this.element) === null || _this$element6 === void 0 ? void 0 : _this$element6.scrollLeft) !== null && _this$element$scrollL !== void 0 ? _this$element$scrollL : 0;
589
586
  }
590
587
  }], [{
591
588
  key: "createTemplate",