question-mark
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.

Remove `parent` as 1st mandatory argument for patch

See original GitHub issue

Having parent as first argument works very well when the all app is designed and wrote with picodom but not that much when used in a mixed libs app. (yes it happens in real world)

You cannot then just render / create a component to get its main node and then append it manually to a parent node of your choice at the time you choose.

To get around this you have to create a fake parent with document.createElement but that add a useless layer.

I’m also not a big fan of that kind of dependency injection and lake of separation which introduce a dependence between the child and its parent, I do prefer the other way, parent knowing its children, but I think this is just a matter of taste.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:43 (31 by maintainers)

github_iconTop GitHub Comments

2reactions
estrattonbaileycommented, Jan 15, 2018

I’ve abandoned my original plans since proposing #91, but I’ve stayed subscribed to this thread because I find it interesting, lol.

On that note, my goal there was twofold:

  1. Create a “meaningful” mount function
  2. Create a simpler patch function (which would satisfy the original problem this issue was opened to address)

As you can see in here, patch accepts two VDOM nodes, and uses internal _ref props that associate mounted nodes to their DOM node counterparts to find parent, children, and nextSibling references.

JorgeBucaran expressed some concern with mutating the node structure with private fields. I don’t share that concern, but I am probably inexperienced in this area so I defer.

The same pattern could definitely be achieved using @mindplay-dk’s proposal of an internal map. I had considered this when I was poking around #91, but was concerned about reliably creating unique indices to associate VDOM nodes to DOM nodes in the map, as well as the additional lookup and memory allocation. Attaching it to the VDOM node via _ref seemed like a more stable and compact solution.

At any rate, my 2¢ is that there should be a separate mount function that initializes a VDOM tree. Then there should be a patch function solely for patching said VDOM tree.

It’s been fun to see this discussion unfold 😃

1reaction
mindplay-dkcommented, Jan 19, 2018

I’ve said that before, but my personal goal is to have something that is simple and useful - I’m only counting bytes to get an idea of whether it’s still small, the impact of making a change, and so on. 1K or 2K is besides the point for me 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Getting TypeError: __init__() missing 1 required ...
Getting TypeError: __init__() missing 1 required positional argument: 'on_delete' when trying to add parent table after child table with entries.
Read more >
Gerrit Code Review - Review Labels
If an approval on an outdated patch set is removed or updated to a value that is not ... The first parent of...
Read more >
Cascade Delete - EF Core | Microsoft Learn
Configuring cascading behaviors triggered when an entity is deleted or severed from its principal/parent.
Read more >
unittest.mock — mock object library — Python 3.11.1 ...
mock provides a core Mock class removing the need to create a host of stubs throughout your test suite. After performing an action,...
Read more >
git-format-patch Documentation - Git
The "patch", which is the "diff -p --stat" output (see git-diff[1]) between the ... The optional <style> argument can be either shallow or...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found