-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update rbx-dom #269
base: main
Are you sure you want to change the base?
Update rbx-dom #269
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,8 @@ pub fn postprocess_dom_for_model(dom: &mut WeakDom) { | |
remove_matching_prop(inst, DomType::UniqueId, "HistoryId"); | ||
// Similar story with ScriptGuid - this is used | ||
// in the studio-only cloud script drafts feature | ||
if class_is_a(&inst.class, "LuaSourceContainer").unwrap_or(false) { | ||
inst.properties.remove("ScriptGuid"); | ||
if class_is_a(inst.class, "LuaSourceContainer").unwrap_or(false) { | ||
inst.properties.remove(&"ScriptGuid".into()); | ||
} | ||
}); | ||
} | ||
|
@@ -41,7 +41,11 @@ where | |
} | ||
|
||
fn remove_matching_prop(inst: &mut DomInstance, ty: DomType, name: &'static str) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably change the type of the |
||
if inst.properties.get(name).map_or(false, |u| u.ty() == ty) { | ||
inst.properties.remove(name); | ||
if inst | ||
.properties | ||
.get(&name.into()) | ||
.map_or(false, |u| u.ty() == ty) | ||
{ | ||
inst.properties.remove(&name.into()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,7 @@ impl Instance { | |
|
||
Some(Self { | ||
dom_ref, | ||
class_name: instance.class.clone(), | ||
class_name: instance.class.to_string(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's probably worth changing the type of |
||
}) | ||
} else { | ||
None | ||
|
@@ -337,14 +337,14 @@ impl Instance { | |
/** | ||
Gets a property for the instance, if it exists. | ||
*/ | ||
pub fn get_property(&self, name: impl AsRef<str>) -> Option<DomValue> { | ||
pub fn get_property(&self, name: &str) -> Option<DomValue> { | ||
INTERNAL_DOM | ||
.lock() | ||
.expect("Failed to lock document") | ||
.get_by_ref(self.dom_ref) | ||
.expect("Failed to find instance in document") | ||
.properties | ||
.get(name.as_ref()) | ||
.get(&name.into()) | ||
Comment on lines
-340
to
+347
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we don't want to change the type of |
||
.cloned() | ||
} | ||
|
||
|
@@ -361,7 +361,7 @@ impl Instance { | |
.get_by_ref_mut(self.dom_ref) | ||
.expect("Failed to find instance in document") | ||
.properties | ||
.insert(name.as_ref().to_string(), value); | ||
.insert(name.as_ref().into(), value); | ||
} | ||
|
||
/** | ||
|
@@ -377,7 +377,7 @@ impl Instance { | |
.get_by_ref(self.dom_ref) | ||
.expect("Failed to find instance in document"); | ||
if let Some(DomValue::Attributes(attributes)) = | ||
inst.properties.get(PROPERTY_NAME_ATTRIBUTES) | ||
inst.properties.get(&PROPERTY_NAME_ATTRIBUTES.into()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be more readable to do |
||
{ | ||
attributes.get(name.as_ref()).cloned() | ||
} else { | ||
|
@@ -398,7 +398,7 @@ impl Instance { | |
.get_by_ref(self.dom_ref) | ||
.expect("Failed to find instance in document"); | ||
if let Some(DomValue::Attributes(attributes)) = | ||
inst.properties.get(PROPERTY_NAME_ATTRIBUTES) | ||
inst.properties.get(&PROPERTY_NAME_ATTRIBUTES.into()) | ||
{ | ||
attributes.clone().into_iter().collect() | ||
} else { | ||
|
@@ -425,14 +425,14 @@ impl Instance { | |
value => value, | ||
}; | ||
if let Some(DomValue::Attributes(attributes)) = | ||
inst.properties.get_mut(PROPERTY_NAME_ATTRIBUTES) | ||
inst.properties.get_mut(&PROPERTY_NAME_ATTRIBUTES.into()) | ||
{ | ||
attributes.insert(name.as_ref().to_string(), value); | ||
} else { | ||
let mut attributes = DomAttributes::new(); | ||
attributes.insert(name.as_ref().to_string(), value); | ||
inst.properties.insert( | ||
PROPERTY_NAME_ATTRIBUTES.to_string(), | ||
PROPERTY_NAME_ATTRIBUTES.into(), | ||
DomValue::Attributes(attributes), | ||
); | ||
} | ||
|
@@ -452,11 +452,11 @@ impl Instance { | |
.get_by_ref_mut(self.dom_ref) | ||
.expect("Failed to find instance in document"); | ||
if let Some(DomValue::Attributes(attributes)) = | ||
inst.properties.get_mut(PROPERTY_NAME_ATTRIBUTES) | ||
inst.properties.get_mut(&PROPERTY_NAME_ATTRIBUTES.into()) | ||
{ | ||
attributes.remove(name.as_ref()); | ||
if attributes.is_empty() { | ||
inst.properties.remove(PROPERTY_NAME_ATTRIBUTES); | ||
inst.properties.remove(&PROPERTY_NAME_ATTRIBUTES.into()); | ||
} | ||
} | ||
} | ||
|
@@ -473,11 +473,11 @@ impl Instance { | |
let inst = dom | ||
.get_by_ref_mut(self.dom_ref) | ||
.expect("Failed to find instance in document"); | ||
if let Some(DomValue::Tags(tags)) = inst.properties.get_mut(PROPERTY_NAME_TAGS) { | ||
if let Some(DomValue::Tags(tags)) = inst.properties.get_mut(&PROPERTY_NAME_TAGS.into()) { | ||
tags.push(name.as_ref()); | ||
} else { | ||
inst.properties.insert( | ||
PROPERTY_NAME_TAGS.to_string(), | ||
PROPERTY_NAME_TAGS.into(), | ||
DomValue::Tags(vec![name.as_ref().to_string()].into()), | ||
); | ||
} | ||
|
@@ -495,7 +495,7 @@ impl Instance { | |
let inst = dom | ||
.get_by_ref(self.dom_ref) | ||
.expect("Failed to find instance in document"); | ||
if let Some(DomValue::Tags(tags)) = inst.properties.get(PROPERTY_NAME_TAGS) { | ||
if let Some(DomValue::Tags(tags)) = inst.properties.get(&PROPERTY_NAME_TAGS.into()) { | ||
tags.iter().map(ToString::to_string).collect() | ||
} else { | ||
Vec::new() | ||
|
@@ -514,7 +514,7 @@ impl Instance { | |
let inst = dom | ||
.get_by_ref(self.dom_ref) | ||
.expect("Failed to find instance in document"); | ||
if let Some(DomValue::Tags(tags)) = inst.properties.get(PROPERTY_NAME_TAGS) { | ||
if let Some(DomValue::Tags(tags)) = inst.properties.get(&PROPERTY_NAME_TAGS.into()) { | ||
let name = name.as_ref(); | ||
tags.iter().any(|tag| tag == name) | ||
} else { | ||
|
@@ -534,14 +534,12 @@ impl Instance { | |
let inst = dom | ||
.get_by_ref_mut(self.dom_ref) | ||
.expect("Failed to find instance in document"); | ||
if let Some(DomValue::Tags(tags)) = inst.properties.get_mut(PROPERTY_NAME_TAGS) { | ||
if let Some(DomValue::Tags(tags)) = inst.properties.get_mut(&PROPERTY_NAME_TAGS.into()) { | ||
let name = name.as_ref(); | ||
let mut new_tags = tags.iter().map(ToString::to_string).collect::<Vec<_>>(); | ||
new_tags.retain(|tag| tag != name); | ||
inst.properties.insert( | ||
PROPERTY_NAME_TAGS.to_string(), | ||
DomValue::Tags(new_tags.into()), | ||
); | ||
inst.properties | ||
.insert(PROPERTY_NAME_TAGS.into(), DomValue::Tags(new_tags.into())); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.