You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2018/01/18 08:34:32 UTC
[16/50] [abbrv] incubator-weex git commit: * [iOS] set the protoType
of Vue to the protoType of globalObject
* [iOS] set the protoType of Vue to the protoType of globalObject
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/b274f4d3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/b274f4d3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/b274f4d3
Branch: refs/heads/master
Commit: b274f4d350cc29e04e64729ae5bea924084c1a90
Parents: 12f82b2
Author: acton393 <zh...@gmail.com>
Authored: Wed Dec 20 11:07:57 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed Dec 20 17:53:12 2017 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/b274f4d3/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
index 5828d3c..13b92c8 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
@@ -471,7 +471,16 @@ _Pragma("clang diagnostic pop") \
JSClassRelease(globalObjectClass);
sdkInstance.instanceJavaScriptContext = [JSContext contextWithJSGlobalContextRef:sandboxGlobalContextRef];
JSGlobalContextRelease(sandboxGlobalContextRef);
- JSObjectSetPrototype(sdkInstance.instanceJavaScriptContext.JSGlobalContextRef,JSContextGetGlobalObject(sdkInstance.instanceJavaScriptContext.JSGlobalContextRef), [instanceContextEnvironment JSValueRef]);
+ JSContextRef instanceContextRef = sdkInstance.instanceJavaScriptContext.JSGlobalContextRef;
+ JSObjectRef globalObject = JSContextGetGlobalObject(sdkInstance.instanceJavaScriptContext.JSGlobalContextRef);
+ for (NSString * key in [[instanceContextEnvironment toDictionary] allKeys]) {
+ JSStringRef propertyName = JSStringCreateWithUTF8CString([key cStringUsingEncoding:NSUTF8StringEncoding]);
+ if ([key isEqualToString:@"Vue"]) {
+ JSObjectSetPrototype(instanceContextRef, JSValueToObject(instanceContextRef, [instanceContextEnvironment valueForProperty:key].JSValueRef, NULL), JSObjectGetPrototype(instanceContextRef, globalObject));
+ }
+ JSObjectSetProperty(instanceContextRef, globalObject, propertyName, [instanceContextEnvironment valueForProperty:key].JSValueRef, 0, NULL);
+ }
+
[sdkInstance.instanceJavaScriptContext evaluateScript:jsBundleString];
}];
} else {