j-component 1.4.9 → 1.4.10
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/package.json +1 -1
- package/src/componentmanager.js +1 -1
- package/src/render/component.js +1 -1
- package/src/render/diff.js +31 -5
package/package.json
CHANGED
package/src/componentmanager.js
CHANGED
|
@@ -136,7 +136,7 @@ class ComponentManager {
|
|
|
136
136
|
if (!exparserNode) return null
|
|
137
137
|
|
|
138
138
|
return getSelectComponentResult(exparserNode)
|
|
139
|
-
}
|
|
139
|
+
}
|
|
140
140
|
caller.createSelectorQuery = () => new SelectorQuery(caller)
|
|
141
141
|
caller.createIntersectionObserver = options => new IntersectionObserver(caller, options)
|
|
142
142
|
caller.setData = (data, callback) => {
|
package/src/render/component.js
CHANGED
package/src/render/diff.js
CHANGED
|
@@ -43,12 +43,16 @@ function diffVt(oldVt, newVt) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// 检查事件
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
if (isSameEvent(oldVt.event, newVt.event)) {
|
|
47
|
+
newVt.event = oldVt.event
|
|
48
|
+
} else {
|
|
49
|
+
Object.keys(oldVt.event).forEach(key => {
|
|
50
|
+
const {name, isCapture, id} = oldVt.event[key]
|
|
48
51
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
exparser.removeListenerFromElement(node, name, id, {capture: isCapture})
|
|
53
|
+
})
|
|
54
|
+
render.updateEvent(node, newVt.event)
|
|
55
|
+
}
|
|
52
56
|
|
|
53
57
|
// 检查子节点
|
|
54
58
|
const oldChildren = oldVt.children
|
|
@@ -122,6 +126,28 @@ function diffAttrs(oldAttrs, newAttrs) {
|
|
|
122
126
|
return isChange ? retAttrs : false
|
|
123
127
|
}
|
|
124
128
|
|
|
129
|
+
/**
|
|
130
|
+
* diff 事件绑定
|
|
131
|
+
*/
|
|
132
|
+
function isSameEvent(oldEvent, newEvent) {
|
|
133
|
+
const oldKeys = Object.keys(oldEvent)
|
|
134
|
+
const newKeys = Object.keys(newEvent)
|
|
135
|
+
|
|
136
|
+
if (oldKeys.length !== newKeys.length) return false
|
|
137
|
+
|
|
138
|
+
return oldKeys.every(key => {
|
|
139
|
+
const oldItem = oldEvent[key]
|
|
140
|
+
const newItem = newEvent[key]
|
|
141
|
+
|
|
142
|
+
return newItem &&
|
|
143
|
+
oldItem.name === newItem.name &&
|
|
144
|
+
oldItem.isCapture === newItem.isCapture &&
|
|
145
|
+
oldItem.isMutated === newItem.isMutated &&
|
|
146
|
+
oldItem.isCatch === newItem.isCatch &&
|
|
147
|
+
oldItem.handler === newItem.handler
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
|
|
125
151
|
/**
|
|
126
152
|
* diff 列表
|
|
127
153
|
*/
|