Created
February 9, 2010 00:42
-
-
Save smparkes/298781 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/shell/js.cpp b/shell/js.cpp | |
index 0750356..f1ac08f 100644 | |
--- a/shell/js.cpp | |
+++ b/shell/js.cpp | |
@@ -2579,9 +2579,23 @@ split_addProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) | |
return JS_TRUE; | |
if (!cpx->isInner && cpx->inner) { | |
/* Make sure to define this property on the inner object. */ | |
- if (!JS_ValueToId(cx, *vp, &asId)) | |
- return JS_FALSE; | |
- return JS_DefinePropertyById(cx, cpx->inner, asId, *vp, NULL, NULL, JSPROP_ENUMERATE); | |
+ | |
+ JSPropertyOp setter = 0; | |
+ JSPropertyOp getter = 0; | |
+ uintN attrs = 0; | |
+ JSBool found; | |
+ | |
+ JS_GetPropertyAttrsGetterAndSetterById(cx, obj, id, &attrs, &found, &getter, &setter); | |
+ | |
+ if (attrs&(JSPROP_GETTER|JSPROP_SETTER)) { | |
+ asId = id; | |
+ } else { | |
+ if (!JS_ValueToId(cx, *vp, &asId)) { | |
+ return JS_FALSE; | |
+ } | |
+ } | |
+ | |
+ return JS_DefinePropertyById(cx, cpx->inner, asId, *vp, getter, setter, attrs | JSPROP_ENUMERATE); | |
} | |
return JS_TRUE; | |
} | |
@@ -4009,9 +4023,9 @@ split_setup(JSContext *cx, JSBool evalcx) | |
outer = split_create_outer(cx); | |
if (!outer) | |
return NULL; | |
- JS_SetGlobalObject(cx, outer); | |
inner = split_create_inner(cx, outer); | |
+ JS_SetGlobalObject(cx, inner); | |
if (!inner) | |
return NULL; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment