Interpreter API: preserve the dashes and underscore when listing properties

This commit is contained in:
Olivier Goffart 2021-08-17 17:01:59 +02:00 committed by Olivier Goffart
parent 77f441b395
commit a39dd6ac4f
4 changed files with 24 additions and 8 deletions

View file

@ -116,8 +116,10 @@ fn create<'cx>(
let persistent_context = persistent_context::PersistentContext::new(cx);
if let Some(args) = cx.argument_opt(0).and_then(|arg| arg.downcast::<JsObject>().ok()) {
let properties =
component_type.properties_and_callbacks().collect::<std::collections::HashMap<_, _>>();
let properties = component_type
.properties_and_callbacks()
.map(|(k, v)| (k.replace('_', "-"), v))
.collect::<std::collections::HashMap<_, _>>();
for x in args.get_own_property_names(cx)?.to_vec(cx)? {
let prop_name = x.to_string(cx)?.value().replace('_', "-");
let value = args.get(cx, x)?;