@@ -22,8 +22,6 @@ import { isRegisteredModule, getModuleDescription } from './module'
22
22
import { isRegisteredComponent } from './component'
23
23
import { getTaskCenter } from '../vdom/operation'
24
24
25
- const moduleProxies = { }
26
-
27
25
function setId ( weex , id ) {
28
26
Object . defineProperty ( weex , '[[CurrentInstanceId]]' , { value : id } )
29
27
}
@@ -79,37 +77,19 @@ export default class WeexInstance {
79
77
return
80
78
}
81
79
82
- // create new module proxy
83
- const proxyName = `${ moduleName } #${ id } `
84
- if ( ! moduleProxies [ proxyName ] ) {
85
- // create registered module apis
86
- const moduleDefine = getModuleDescription ( moduleName )
87
- const moduleApis = { }
88
- for ( const methodName in moduleDefine ) {
89
- Object . defineProperty ( moduleApis , methodName , {
90
- enumerable : true ,
91
- configurable : true ,
92
- get : ( ) => moduleGetter ( id , moduleName , methodName ) ,
93
- set : fn => moduleSetter ( id , moduleName , methodName , fn )
94
- } )
95
- }
96
-
97
- // create module Proxy
98
- // if (typeof Proxy === 'function') {
99
- // moduleProxies[proxyName] = new Proxy(moduleApis, {
100
- // get (target, methodName) {
101
- // if (methodName in target) {
102
- // return target[methodName]
103
- // }
104
- // console.warn(`[JS Framework] using unregistered method "${moduleName}.${methodName}"`)
105
- // return moduleGetter(id, moduleName, methodName)
106
- // }
107
- // })
108
- // }
109
- moduleProxies [ proxyName ] = moduleApis
80
+ // create registered module apis
81
+ const moduleProxy = Object . create ( null )
82
+ const moduleDefine = getModuleDescription ( moduleName )
83
+ for ( const methodName in moduleDefine ) {
84
+ Object . defineProperty ( moduleProxy , methodName , {
85
+ enumerable : true ,
86
+ configurable : true ,
87
+ get : ( ) => moduleGetter ( id , moduleName , methodName ) ,
88
+ set : fn => moduleSetter ( id , moduleName , methodName , fn )
89
+ } )
110
90
}
111
91
112
- return moduleProxies [ proxyName ]
92
+ return moduleProxy
113
93
}
114
94
115
95
supports ( condition ) {
@@ -132,7 +112,7 @@ export default class WeexInstance {
132
112
importScript ( src , options = { } ) {
133
113
const id = getId ( this )
134
114
const taskCenter = getTaskCenter ( id )
135
- return new Promise ( ( resolve , reject ) => {
115
+ return new Promise ( function ( resolve , reject ) {
136
116
if ( ! taskCenter || typeof taskCenter . send !== 'function' ) {
137
117
reject ( new Error ( `[JS Framework] Failed to import script "${ src } ", `
138
118
+ `no taskCenter (${ id } ) matched.` ) )
0 commit comments