ZIM016 clone bug?

I have this app that works well with ZIM015 but when I change to ZIM016 the "clone()" doesn't entirely clone everything.

Just uncomment the last line to see the difference.

Is this the file you mean?

Sorry, this one.

1 Like

The clone() of a Tile() with unique:true was adjusted in 016. The clone() in 015 was not really working as you expected anyway... it moved the objects over to the new Tile. The answer is never expect a cloned ZIM shape like Rectangle(), Circle(), etc. to also clone anything inside it. These shapes are not supposed to be used as Containers. Instead, make a Container() and add the shape and any other content - then clone the Container. That works.

So adjust your code:

const rec1 = new Container(1200/i, 80);
new Rectangle({ width: rec1.width, height: rec1.height, color: blue, borderColor: gray, borderWidth: 2 }).addTo(rec1);

1 Like

I tried almost everything, not this. Thanks. :clap:

1 Like

Yes - a tricky one.

Simplify... clone the Tile and see what happens. Then clone the Rectangle with a Label in it and see what happens... oh... no Label. Look up clone on the Rectangle...

Maybe one day... we will revisit this. But there are Rectangles everywhere and most of the time they do not have any content... so when we clone a Button for instance, it is a bit of a waste to then go check for children of the Rectangle in a Button, etc. So, since, the shapes are not really supposed to have content we chose not to recursively clone them.

I didn't get to the warning when I read it. :slight_smile:

1 Like