native-document 1.0.111 → 1.0.113-clear

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.
@@ -1,21 +1,15 @@
1
1
  import { ElementCreator } from "../ElementCreator";
2
2
 
3
- export const OPERATIONS = {
4
- HYDRATE_TEXT: 1,
5
- ATTACH_METHOD: 2,
6
- HYDRATE_ATTRIBUTES: 3,
7
- HYDRATE_FULL: 4,
8
- };
9
-
10
3
 
4
+ export const cloneBindingsDataCache = new WeakMap();
11
5
 
12
6
  const pathProcess = (target, path, data) => {
13
- if(path.operation === OPERATIONS.HYDRATE_TEXT) {
7
+ if(path.HYDRATE_TEXT) {
14
8
  const value = path.value;
15
9
  ElementCreator.bindTextNode(target, path.isString ? data[0][value] : value.apply(null, data));
16
10
  return;
17
11
  }
18
- if(path.operation === OPERATIONS.ATTACH_METHOD || path.operation === OPERATIONS.HYDRATE_FULL) {
12
+ if(path.ATTACH_METHOD) {
19
13
  const bindingData = path.bindingData;
20
14
  for(let i = 0, length = bindingData._attachLength; i < length; i++) {
21
15
  const method = bindingData.attach[i];
@@ -24,7 +18,7 @@ const pathProcess = (target, path, data) => {
24
18
  });
25
19
  }
26
20
  }
27
- if(path.operation === OPERATIONS.HYDRATE_ATTRIBUTES || path.operation === OPERATIONS.HYDRATE_FULL) {
21
+ if(path.HYDRATE_ATTRIBUTES) {
28
22
  path.hydrator(target, path.bindingData, data);
29
23
  }
30
24
  };
@@ -126,7 +120,23 @@ export const hydrateClonedNode = (root, data, paths, pathSize) => {
126
120
  target = $applyBindingParents[path.parentId].childNodes[path.index];
127
121
  $applyBindingParents[path.id] = target;
128
122
 
129
- pathProcess(target, path, data);
123
+ if(path.HYDRATE_TEXT) {
124
+ const value = path.value;
125
+ ElementCreator.bindTextNode(target, path.isString ? data[0][value] : value.apply(null, data));
126
+ continue;
127
+ }
128
+ if(path.ATTACH_METHOD) {
129
+ const bindingData = path.bindingData;
130
+ for(let i = 0, length = bindingData._attachLength; i < length; i++) {
131
+ const method = bindingData.attach[i];
132
+ target.nd[method.methodName](function() {
133
+ method.fn.call(this, ...data, ...arguments);
134
+ });
135
+ }
136
+ }
137
+ if(path.HYDRATE_ATTRIBUTES) {
138
+ path.hydrator(target, path.bindingData, data);
139
+ }
130
140
  }
131
141
 
132
142
  for (let i = 0; i <= pathSize; i++) {