mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-25 02:27:00 -06:00
Merge pull request #851 from Ni-zav/fix/811-script-object-identity-20261011
fix(script): preserve item and layer wrapper identity # Conflicts: # crates/script/src/tests.rs
This commit is contained in:
@@ -930,3 +930,36 @@ fn import_options_preserve_layered_psd_compositions() {
|
||||
assert_eq!(bad.result, json!(false));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn script_item_and_layer_identity_survives_repeated_access() {
|
||||
let mut s = session();
|
||||
let o = ok(
|
||||
&mut s,
|
||||
r#"
|
||||
var c = app.project.items.addComp("Identity", 120, 80, 1, 3, 25);
|
||||
var parent = c.layers.addNull(), child = c.layers.addNull();
|
||||
child.parent = parent;
|
||||
[
|
||||
parent.containingComp === c,
|
||||
c.layer(1) === c.layer(1),
|
||||
child.parent === parent,
|
||||
app.project.item(1) === app.project.item(1),
|
||||
app.project.item(1) === c,
|
||||
app.project.itemByID(c.id) === c
|
||||
]
|
||||
"#,
|
||||
);
|
||||
assert_eq!(o.result, json!([true, true, true, true, true, true]));
|
||||
// Reusing item and layer IDs in a new project must not alias old wrappers.
|
||||
let o = ok(
|
||||
&mut s,
|
||||
r#"
|
||||
var old = app.project.item(1);
|
||||
app.newProject();
|
||||
var next = app.project.items.addComp("New", 120, 80, 1, 3, 25);
|
||||
[old !== next, app.project.item(1) === next]
|
||||
"#,
|
||||
);
|
||||
assert_eq!(o.result, json!([true, true]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user