Skip to content

Instantly share code, notes, and snippets.

@smparkes
Created February 9, 2010 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smparkes/298781 to your computer and use it in GitHub Desktop.
Save smparkes/298781 to your computer and use it in GitHub Desktop.
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