@@ -199,21 +199,6 @@ function getPropsMethod(wxInst, key) {
199
199
}
200
200
}
201
201
202
- /**
203
- * onX
204
- * @param name
205
- * @returns {boolean }
206
- */
207
- function isEventProp ( name ) {
208
- if ( ! name || name . length <= 3 ) return false ;
209
- const trCode = name . charCodeAt ( 2 ) ;
210
- return name . charCodeAt ( 0 ) === 111
211
- && name . charCodeAt ( 1 ) === 110
212
- && trCode >= 65
213
- && trCode <= 90 ;
214
- }
215
-
216
-
217
202
// 外层占位View, 作用是撑满小程序自定义组件生成的View
218
203
const DEFAULTCONTAINERSTYLE = '_5_' ;
219
204
@@ -332,6 +317,37 @@ function cleanPageComp(pageComp) {
332
317
invokeWillUnmount ( allChildren ) ;
333
318
}
334
319
320
+ function reactCompHelper ( obj ) {
321
+ obj . properties = {
322
+ ...obj . properties ,
323
+ diuu : null ,
324
+ } ;
325
+
326
+ const rawAttached = obj . attached ;
327
+ obj . attached = function ( ) {
328
+ const rawData = this . data ;
329
+ Object . defineProperty ( this , 'data' , {
330
+ get : function ( ) {
331
+ const compInst = instanceManager . getCompInstByUUID ( rawData . diuu ) ;
332
+ return {
333
+ ...rawData ,
334
+ ...compInst . props
335
+ }
336
+ } ,
337
+ } ) ;
338
+ rawAttached && rawAttached . call ( this ) ;
339
+ instanceManager . setWxCompInst ( this . data . diuu , this ) ;
340
+ } ;
341
+
342
+ const rawDetached = obj . detached ;
343
+ obj . detached = function ( ) {
344
+ rawDetached && rawDetached . call ( this ) ;
345
+ instanceManager . removeUUID ( this . data . diuu ) ;
346
+ } ;
347
+
348
+ return obj
349
+ }
350
+
335
351
/**
336
352
* Copyright (c) Areslabs.
337
353
*
@@ -1591,7 +1607,7 @@ function updateRNBaseComponent(vnode, parentInst, parentContext, data, oldData,
1591
1607
} else {
1592
1608
data [ `${ diuuKey } onRefreshPassed` ] = false ;
1593
1609
}
1594
- } else if ( isEventProp ( k ) ) {
1610
+ } else if ( typeof v === 'function' ) {
1595
1611
inst . props [ k ] = reactEnvWrapper ( v ) ;
1596
1612
} else {
1597
1613
//避免小程序因为setData undefined报错
@@ -1862,7 +1878,7 @@ function updateBaseView(vnode, parentInst, parentContext, data, oldData, dataPat
1862
1878
1863
1879
if ( k === 'src' ) {
1864
1880
data [ `${ vnodeDiuu } ${ k } ` ] = v . uri || v ;
1865
- } else if ( isEventProp ( k ) ) {
1881
+ } else if ( typeof v === 'function' ) {
1866
1882
eventProps . push ( k ) ;
1867
1883
} else if ( k === 'mode' ) {
1868
1884
data [ `${ vnodeDiuu } ${ k } ` ] = resizeMode ( v ) ;
@@ -2568,10 +2584,11 @@ var index = {
2568
2584
instanceManager,
2569
2585
getPropsMethod,
2570
2586
unstable_batchedUpdates,
2571
- renderApp
2587
+ renderApp,
2588
+ reactCompHelper
2572
2589
} ;
2573
2590
const h = createElement ;
2574
2591
const render$1 = deprecated ;
2575
2592
2576
2593
export default index ;
2577
- export { Component , FuncComponent , HocComponent , PureComponent , RNBaseComponent , WxNormalComp , createElement , flattenStyle , getPropsMethod , h , instanceManager , parseElement , render$1 as render , renderApp , renderPage , styleType , tackleWithStyleObj , unstable_batchedUpdates } ;
2594
+ export { Component , FuncComponent , HocComponent , PureComponent , RNBaseComponent , WxNormalComp , createElement , flattenStyle , getPropsMethod , h , instanceManager , parseElement , reactCompHelper , render$1 as render , renderApp , renderPage , styleType , tackleWithStyleObj , unstable_batchedUpdates } ;
0 commit comments