mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Factor out code to call JS_DeletePropertyById2.
I'll need to write the same code again for cross-origin wrappers.
This commit is contained in:
parent
f2373ceee7
commit
3274071b2c
2 changed files with 15 additions and 9 deletions
|
@ -39,6 +39,7 @@ use js::jsapi::{JSContext, JSObject, JSBool, jsid, JSClass};
|
|||
use js::jsapi::{JSFunctionSpec, JSPropertySpec};
|
||||
use js::jsapi::{JS_NewGlobalObject, JS_InitStandardClasses};
|
||||
use js::jsapi::{JSString};
|
||||
use js::jsapi::JS_DeletePropertyById2;
|
||||
use js::jsfriendapi::JS_ObjectToOuterObject;
|
||||
use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType;
|
||||
use js::jsval::JSVal;
|
||||
|
@ -682,6 +683,17 @@ pub fn cx_for_dom_object<T: Reflectable>(obj: &T) -> *mut JSContext {
|
|||
cx_for_dom_reflector(obj.reflector().get_jsobject())
|
||||
}
|
||||
|
||||
pub unsafe fn delete_property_by_id(cx: *mut JSContext, object: *mut JSObject,
|
||||
id: jsid, bp: &mut bool) -> bool {
|
||||
let mut value = UndefinedValue();
|
||||
if JS_DeletePropertyById2(cx, object, id, &mut value) == 0 {
|
||||
return false;
|
||||
}
|
||||
|
||||
*bp = value.to_boolean();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Results of `xml_name_type`.
|
||||
#[deriving(PartialEq)]
|
||||
pub enum XMLName {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue