mirror of
https://github.com/storytold/figcraft.git
synced 2026-12-02 02:45:01 -06:00
M3: an effects key naming no effect's field binds nothing (#2055)
Review follow-up: `effects/x/radius`, `effects/0` and `effects` name no effect's field, but `list_binding` doesn't parse them, so the layer's check took them for some other field and kept an inert binding. A key under `effects` that names no effect's field is now refused as well.
This commit is contained in:
@@ -661,11 +661,12 @@ fn effect_field(doc: &Document, node: NodeId, i: usize, field: &str) -> Option<V
|
||||
}
|
||||
|
||||
/// Whether `node` has the field a binding key names. Only effect fields are checked: a layer has
|
||||
/// `effects/<i>/<field>` when its effect `i` has that field (a drop shadow has no `refraction`).
|
||||
/// `effects/<i>/<field>` when its effect `i` has that field (a drop shadow has no `refraction`),
|
||||
/// and an `effects…` key naming no effect's field (`effects/x/radius`, `effects/0`) has none.
|
||||
pub fn has_field(doc: &Document, node: NodeId, field: &str) -> bool {
|
||||
match super::lists::list_binding(field) {
|
||||
Some((BoundList::Effects, i, f)) => effect_field(doc, node, i, f).is_some(),
|
||||
_ => true,
|
||||
_ => field.split('/').next() != Some(BoundList::Effects.prefix()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user