render-core 1.4.21 → 1.4.22

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.
@@ -5,42 +5,50 @@ import { locateInputAddress } from "../../system/utility/react/sectionUtility";
5
5
  * @param updater
6
6
  */
7
7
  export function get_proxy_for_method(data, updater) {
8
- var proxyCache = new WeakMap();
9
- function createDeepProxy(target) {
10
- if (proxyCache.has(target)) {
11
- return proxyCache.get(target);
12
- }
13
- var proxy = new Proxy(target, {
8
+ function isPlainObject(value) {
9
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
10
+ }
11
+ function createProxy(target) {
12
+ return new Proxy(target, {
14
13
  set: function (obj, prop, value) {
15
- if (value !== null && typeof value === 'object') {
16
- value = createDeepProxy(value);
14
+ var existed = prop in obj;
15
+ if (isPlainObject(value)) {
16
+ value = wrapObject(value);
17
17
  }
18
18
  Reflect.set(obj, prop, value);
19
- update_Render(updater);
20
- try {
21
- if (updater.watcher && typeof updater.watcher[prop] === 'function') {
22
- updater.watcher[prop](obj[prop], value);
19
+ // Only activate updater when an existing property of a plain object changes.
20
+ // Adding new properties or mutating arrays does not activate it.
21
+ if (isPlainObject(obj) && existed) {
22
+ update_Render(updater);
23
+ try {
24
+ if (updater.watcher && typeof updater.watcher[prop] === 'function') {
25
+ updater.watcher[prop](obj[prop], value);
26
+ }
23
27
  }
28
+ catch (error) {
29
+ // silently ignore missing watchers
30
+ }
31
+ locateInputAddress(updater);
32
+ Reflect.deleteProperty(updater, 'origin');
24
33
  }
25
- catch (error) {
26
- // silently ignore missing watchers
27
- }
28
- locateInputAddress(updater);
29
- Reflect.deleteProperty(updater, 'origin');
30
34
  return true;
31
- },
32
- get: function (obj, prop) {
33
- var value = Reflect.get(obj, prop);
34
- if (value !== null && typeof value === 'object') {
35
- return createDeepProxy(value);
36
- }
37
- return value;
38
35
  }
39
36
  });
40
- proxyCache.set(target, proxy);
41
- return proxy;
42
37
  }
43
- return createDeepProxy(data);
38
+ function wrapObject(target) {
39
+ if (!isPlainObject(target)) {
40
+ return target;
41
+ }
42
+ for (var _i = 0, _a = Object.keys(target); _i < _a.length; _i++) {
43
+ var key = _a[_i];
44
+ var value = target[key];
45
+ if (isPlainObject(value)) {
46
+ target[key] = wrapObject(value);
47
+ }
48
+ }
49
+ return createProxy(target);
50
+ }
51
+ return wrapObject(data);
44
52
  }
45
53
  /**
46
54
  * @param origin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "render-core",
3
- "version": "1.4.21",
3
+ "version": "1.4.22",
4
4
  "description": "The extendable javascript web framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",