targetj 1.0.174 → 1.0.176

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/README.md CHANGED
@@ -51,7 +51,29 @@ Or in HTML (no JavaScript required), using tg- attributes that mirror object lit
51
51
  tg-width="[{ list: [100, 250, 100] }, 50, 10]"
52
52
  tg-height$="return this.prevTargetValue / 2;">
53
53
  </div>
54
- ```
54
+ ```
55
+ Or a combination of JavaScript and HTML, linked together using the same HTML ID. In the example below, both the object and the `<div>` element are bound using the ID 'box'. The object uses the `<div>` as its base element, combining the background from the element with the width and height from the object:
56
+
57
+ ```javascript
58
+ import { App } from "targetj";
59
+
60
+ App({
61
+ id: 'box',
62
+ width: [{ list: [100, 250, 100] }, 50, 10],
63
+ _height$() {
64
+ return this.prevTargetValue / 2;
65
+ }
66
+ });
67
+ ```
68
+
69
+ ```html
70
+ <div
71
+ id="box"
72
+ tg-background="mediumpurple"
73
+ </div>
74
+ ```
75
+
76
+
55
77
 
56
78
  ### Simple Loading API Example
57
79
 
@@ -31,6 +31,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
31
31
  */
32
32
  var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
33
33
  function BaseModel(type, targets, oid) {
34
+ var _targets;
34
35
  _classCallCheck(this, BaseModel);
35
36
  if (_typeof(type) === 'object' && typeof targets === 'undefined') {
36
37
  targets = type;
@@ -47,7 +48,12 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
47
48
  this.oid = oid;
48
49
  this.oidNum = 0;
49
50
  }
50
- _App.App.tmodelIdMap[this.oid] = this;
51
+ if (!((_targets = targets) !== null && _targets !== void 0 && _targets.sourceDom) && _TUtil.TUtil.isDefined(oid)) {
52
+ this.originalId = oid;
53
+ }
54
+ if (!_App.App.tmodelIdMap[this.oid]) {
55
+ _App.App.tmodelIdMap[this.oid] = this;
56
+ }
51
57
  this._state = {};
52
58
  }
53
59
  return _createClass(BaseModel, [{
@@ -262,6 +268,12 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
262
268
  key: "initTargets",
263
269
  value: function initTargets() {
264
270
  var _this = this;
271
+ this.originalTargetNames = Object.keys(this.targets);
272
+ if (_TUtil.TUtil.isDefined(this.originalId) && (0, _App.getDomTModelById)(this.originalId)) {
273
+ _TUtil.TUtil.mergeTargets((0, _App.getDomTModelById)(this.originalId), this);
274
+ this.toDiscard = true;
275
+ return;
276
+ }
265
277
  this.actualValues = _TModelUtil.TModelUtil.defaultActualValues();
266
278
  this.targetValues = {};
267
279
  this.activeTargetMap = {};
@@ -74,7 +74,7 @@ var LoadingManager = exports.LoadingManager = /*#__PURE__*/function () {
74
74
  var _this = this;
75
75
  var urls = Array.isArray(url) ? url : [url];
76
76
  urls.forEach(function (singleUrl) {
77
- var fetchId = "".concat(tmodel.oid, "_").concat(singleUrl, "_").concat(JSON.stringify(query));
77
+ var fetchId = query ? "".concat(tmodel.oid, "_").concat(singleUrl, "_").concat(JSON.stringify(query)) : "".concat(tmodel.oid, "_").concat(singleUrl);
78
78
  _this.fetchCommon(fetchId, cacheId, tmodel, _this.fetchingAPIMap, function () {
79
79
  _this.ajaxAPI(singleUrl, query, _this.fetchingAPIMap[fetchId]);
80
80
  });
package/build/TModel.js CHANGED
@@ -134,33 +134,31 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
134
134
  var foundKey = Object.keys(this.actualValues).find(function (key) {
135
135
  return _this2.actualValues[key] === child;
136
136
  });
137
- var originalId = child.id;
138
137
  if (foundKey) {
139
138
  child = new TModel(child.id || foundKey, child);
140
139
  this.actualValues[foundKey] = child;
141
140
  } else if (_TUtil.TUtil.isDefined(child.otype)) {
142
141
  child = new TModel(child.otype, child);
143
142
  } else if (_TUtil.TUtil.isDefined(child.id)) {
144
- child = new TModel(child.id, child, child.sourceDom ? child.id : undefined);
143
+ child = new TModel(child.id, child, child.id);
145
144
  } else {
146
145
  child = new TModel("".concat(this.oid, "_"), child);
147
146
  }
148
- if (!child.targets['sourceDom'] && _TUtil.TUtil.isDefined(originalId)) {
149
- child.originalId = originalId;
150
- }
151
- }
152
- this.addedChildren.push({
153
- index: index,
154
- child: child
155
- });
156
- child.parent = this;
157
- if (child.updatingTargetList.length > 0) {
158
- this.addToUpdatingChildren(child);
159
147
  }
160
- if (child.activeTargetList.length > 0) {
161
- this.addToActiveChildren(child);
148
+ if (!child.toDiscard) {
149
+ this.addedChildren.push({
150
+ index: index,
151
+ child: child
152
+ });
153
+ child.parent = this;
154
+ if (child.updatingTargetList.length > 0) {
155
+ this.addToUpdatingChildren(child);
156
+ }
157
+ if (child.activeTargetList.length > 0) {
158
+ this.addToActiveChildren(child);
159
+ }
160
+ child.activate();
162
161
  }
163
- child.activate();
164
162
  }
165
163
  return this;
166
164
  }
@@ -190,10 +188,6 @@ var TModel = exports.TModel = /*#__PURE__*/function (_BaseModel) {
190
188
  this.addedChildren.forEach(function (_ref) {
191
189
  var index = _ref.index,
192
190
  child = _ref.child;
193
- if (_TUtil.TUtil.isDefined(child.originalId) && (0, _App.getDomTModelById)(child.originalId) && !child.targets['sourceDom']) {
194
- _TUtil.TUtil.mergeTargets((0, _App.getDomTModelById)(child.originalId), child);
195
- return;
196
- }
197
191
  if (_this3.allChildrenMap[child.oid]) {
198
192
  return;
199
193
  }
package/build/TUtil.js CHANGED
@@ -217,14 +217,21 @@ var TUtil = exports.TUtil = /*#__PURE__*/function () {
217
217
  }, {
218
218
  key: "mergeTargets",
219
219
  value: function mergeTargets(tmodel1, tmodel2) {
220
+ var _tmodel1$originalTarg;
220
221
  var sourceTargets = tmodel2.targets;
222
+ var targetNames = tmodel2.originalTargetNames;
221
223
  var destTargets = tmodel1.targets;
222
- Object.keys(sourceTargets).forEach(function (key) {
224
+ var newTargets = [];
225
+ targetNames.forEach(function (key) {
223
226
  if (!TUtil.isDefined(destTargets[key])) {
224
- destTargets[key] = sourceTargets[key];
225
- tmodel1.processNewTarget(key);
227
+ newTargets.push(key);
226
228
  }
227
229
  });
230
+ (_tmodel1$originalTarg = tmodel1.originalTargetNames).push.apply(_tmodel1$originalTarg, newTargets);
231
+ newTargets.forEach(function (key) {
232
+ destTargets[key] = sourceTargets[key];
233
+ tmodel1.processNewTarget(key);
234
+ });
228
235
  }
229
236
  }]);
230
237
  }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "targetj",
3
- "version": "1.0.174",
3
+ "version": "1.0.176",
4
4
  "description": "TargetJS is a JavaScript framework designed for creating animated and efficient web user interfaces.",
5
5
  "keywords": ["targetjs"],
6
6
  "main": "Export.js",