shablon 0.0.1-rc.7 → 0.0.1-rc.8

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
@@ -174,8 +174,6 @@ data.activity = "rest"
174
174
  Watch registers a callback function that fires on initialization and
175
175
  every time any of its evaluated `store` reactive properties change.
176
176
 
177
- Note that for reactive getters, initially the watch `trackedFunc` will be invoked twice because we register a second internal watcher to cache the getter value.
178
-
179
177
  It returns a "watcher" object that could be used to `unwatch()` the registered listener.
180
178
 
181
179
  _Optionally also accepts a second callback function that is excluded from the evaluated
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.1-rc.7",
2
+ "version": "0.0.1-rc.8",
3
3
  "name": "shablon",
4
4
  "description": "No-build JavaScript framework for Single-page applications",
5
5
  "author": "Gani Georgiev",
package/src/state.js CHANGED
@@ -234,14 +234,13 @@ function createProxy(obj, pathWatcherIds) {
234
234
  // if not invoked inside a watch function, call the original
235
235
  // getter to ensure that an up-to-date value is computed
236
236
  if (!activeWatcher) {
237
- return descriptors[prop]?.get?.call(obj);
237
+ return descriptors[prop].get.call(obj);
238
238
  }
239
239
 
240
240
  getterProp = prop;
241
241
 
242
242
  // replace with an internal property so that reactive statements can be cached
243
243
  prop = "@@" + prop;
244
- Object.defineProperty(obj, prop, { writable: true, enumerable: false });
245
244
  }
246
245
 
247
246
  // detached child?
@@ -364,14 +363,24 @@ function createProxy(obj, pathWatcherIds) {
364
363
 
365
364
  let getFunc = descriptors[getterProp].get.bind(obj);
366
365
 
367
- let getWatcher = watch(getFunc, (result) => (receiver[prop] = result));
366
+ let getWatcher = watch(getFunc, (result) => {
367
+ if (!obj.hasOwnProperty(prop)) {
368
+ Object.defineProperty(obj, prop, {
369
+ writable: true,
370
+ enumerable: false,
371
+ value: result,
372
+ });
373
+ } else {
374
+ receiver[prop] = result;
375
+ }
376
+ });
368
377
 
369
378
  getWatcher[onRemoveSym] = () => {
370
379
  descriptors[getterProp]?.watchers?.delete(watcherId);
371
380
  };
372
381
 
373
382
  // update with the cached get value after the above watch initialization
374
- propVal = obj[prop]
383
+ propVal = obj[prop];
375
384
  }
376
385
  }
377
386
 
package/src/template.js CHANGED
@@ -117,7 +117,7 @@ function tag(tagName, attrs = {}, ...children) {
117
117
  return;
118
118
  }
119
119
 
120
- const result = val(el, attr)
120
+ const result = val(el, attr);
121
121
 
122
122
  if (useSetAttr) {
123
123
  el.setAttribute(attr, result);