Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

embed() doesn't unembed() previous parent

See original GitHub issue

If I’m reading the docs correctly, the entire embedding feature is designed like a tree:

cell B might or might not have a parent. If it does, it can be cell A. cell A might or might not have children. If it does, they can be [cell B, cell C, cell D...].

The relationship from parent to children is represented by an array on values: getEmbeds() returns an array. The other way around (from any given child to it’s parent) is represented as a single id: parent() returns an id.

After playing for some days with this feature I hit a bug with how the embed() method works: it doesn’t check (and unembed()) whether the cell that’s going to be embedded is already embedded in another cell. This leads to an unreachable relation from the cell to it’s previous parent (and a broken tree).

Example (pseudo-code):

parent1 = cell()
parent2 = cell()
child = cell()


parent1.getEmbeds()    <-- [child]
child.parent()         <-- parent1

parent2.getEmbeds()    <-- [child]
child.parent()         <-- parent2

parent1.getEmbeds()    <-- [child]     // shouldn't happen. "child" belongs to "parent2" now.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

kumilinguscommented, Sep 23, 2022

I was only worried about the case where we internally un-embed the cell instead of throwing error (either as default behavior or with force option). When we throw an error, the responsibility is on the user. Not adding the force option now was a conscious decision for two reasons:

  • we are in the release process, didn’t want to spend time on this as it is not trivial and definitely not a blocker
  • keep the API clean if (a.isEmbedded()) { a.getParentCell().unembed(a); } c.embed(a);
kumilinguscommented, Jul 18, 2022

I am aware that none of the batch logic is documented (as far as I know it’s useful only with JointJS+), but you can use graph.hasActiveBatch('fit-embeds').

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calling a parent window function from an iframe - Stack Overflow
If a window does not have a parent, its parent property is a reference to itself. ... will only work on same...
Read more >
<iframe>: The Inline Frame element - HTML - MDN Web Docs
The HTML element represents a nested browsing context, embedding another HTML page into the current one.
Read more >
go:embed <path to file in parent directory> doesn't work #46056
I've fixed my original post. 1
Read more >
Access and edit embed codes – Help Center - Vimeo
You can access the embed code for your video in a few different ways: The video settings page: You can find your video's...
Read more >
How to embed a TrueType font in a document
Microsoft Word allows you to embed a TrueType font in a Word document so that you can ... If a font does not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found