@@ -80,15 +80,14 @@ function checkBubble (el) {
80
80
* - with all weex events: stop propagation by default.
81
81
* - with click and scroll events: weex$tap and weex$scroll.
82
82
*/
83
- function bindEvents ( evts , el , attrs , weexEvents ) {
83
+ function bindEvents ( evts , el , attrs , weexEvents , appearAttached ) {
84
84
const evtKeys = Object . keys ( evts )
85
- el . _markedAppear = false
86
85
for ( let i = 0 , l = evtKeys . length ; i < l ; i ++ ) {
87
86
const key = evtKeys [ i ]
88
87
const transKey = transEvtsMap [ key ]
89
88
const evtName = transKey || key
90
- if ( transKey && ! el . _markedAppear ) {
91
- el . _markedAppear = true
89
+ if ( transKey && ! appearAttached . value ) {
90
+ appearAttached . value = true
92
91
attrs . push ( {
93
92
name : `weex-appear` ,
94
93
value : '""'
@@ -151,23 +150,44 @@ module.exports = function eventsHook (
151
150
152
151
const { weexEvents } = this . config
153
152
let evts = el . events
154
- const nativeEvts = el . nativeEvents
153
+ let nativeEvts = el . nativeEvents
155
154
156
- try {
155
+ if ( nativeEvts && el . _builtIn ) {
156
+ /**
157
+ * for div, image, text, cell, a, ...
158
+ * user should bind all events without .native.
159
+ */
160
+ nativeEvts = null
161
+ delete el . nativeEvents
162
+ }
163
+ if ( el . _weexRegistered ) {
164
+ /**
165
+ * for slider, list, ...
166
+ * user should bind events without .native.
167
+ * in our events handling, all events should transfer to
168
+ * .native binding.
169
+ */
170
+ delete el . nativeEvents
171
+ nativeEvts = null
157
172
if ( evts ) {
158
- bindEvents ( evts , el , attrs , weexEvents )
159
- }
160
- if ( nativeEvts ) {
161
- bindEvents ( nativeEvts , el , attrs , weexEvents )
173
+ nativeEvts = el . nativeEvents = evts
162
174
}
163
- else {
164
- delete el . nativeEvents
165
- }
166
- } catch ( err ) {
167
- console . error ( 'err=======>' , err )
175
+ evts = null
176
+ delete el . events
177
+ }
178
+
179
+ const appearAttached = {
180
+ value : false
181
+ }
182
+ if ( evts ) {
183
+ bindEvents ( evts , el , attrs , weexEvents , appearAttached )
184
+ }
185
+ if ( nativeEvts ) {
186
+ bindEvents ( nativeEvts , el , attrs , weexEvents , appearAttached )
187
+ }
188
+ else {
189
+ delete el . nativeEvents
168
190
}
169
-
170
- delete el . _markedAppear
171
191
172
192
/**
173
193
* binding a weex$tap to <a> element to stop propagation if there
0 commit comments