Skip to content

Commit

Permalink
can us Object instead of JsValue
Browse files Browse the repository at this point in the history
  • Loading branch information
badetitou committed Mar 20, 2024
1 parent 4d28b1b commit 5671a5c
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions jackson-wasm/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::default_context_group::DEFAULT_CONTEXT_GROUP;
use js_sys::RegExp;
use js_sys::{Object, RegExp};
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
Expand Down Expand Up @@ -102,22 +102,10 @@ mod Reflect {
}
}

#[allow(non_snake_case)]
mod Object {
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = Object)]
pub fn getPrototypeOf(o: JsValue) -> JsValue;

}
}

#[wasm_bindgen]
pub fn find_metadata_by_metadata_key_with_context(
metadata_key_with_context: &str,
target: JsValue,
target: Object,
property_key: Option<String>,
context: Option<JsonStringifierParserCommonContext>,
) -> JsValue {
Expand All @@ -142,7 +130,7 @@ pub fn find_metadata_by_metadata_key_with_context(

let has_context = context.is_some();
let concrete_context = context.unwrap();
let mut parent = target;
let mut parent = target.clone();

while json_decorator_options.is_none() && parent_name(&parent).is_ok() {
if json_decorator_options.is_none()
Expand Down Expand Up @@ -172,7 +160,11 @@ pub fn find_metadata_by_metadata_key_with_context(
}
// web_sys::console::log_1(&"XX go here".into());

parent = Object::getPrototypeOf(parent);
let prototype = js_sys::Reflect::get_prototype_of(&parent);
if prototype.is_err() {
break;
}
parent = prototype.unwrap();
}

if json_decorator_options.is_some() {
Expand Down

0 comments on commit 5671a5c

Please sign in to comment.