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.

Patch prepends result to parent.

See original GitHub issue

By default the patch method prepends the result to the parent element. This means that if you have a page rendered on the server with some default content and then use path on the parent element, Pidocom prepends using element.insertBefore. Case in view, say you have a header with title, menu, etc. rendered on the server and then try to use patch to inject content into the document body at load time. Picodom prepends that content before the header, pushing it down. The only way to avoid this as it stands is to always use empty containers with patch. This seams very wasteful. It would be nice if the insertion behavior followed norms that developers expect so they aren’t scratching their heads when things are prepended. Otherwise, hey Jorge, good job on this project.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
mindplay-dkcommented, Jan 11, 2018

This might be mitigated also by the change proposed here in #89 - for the top-most call to patch, order would not be an issue or a concern at all, since the caller would be responsible for designating exactly the element they want to patch; it’s order wouldn’t be affected at all.

0reactions
jorgebucarancommented, Feb 27, 2018

@rbiggs In the new API:

import { h, patch } from "patchdom"

document.body.appendChild(
  patch( h("h1", {}, "Hello") )
)

The patch function now returns an element, if none is given, allowing you to append it to a container if that’s what you want. If you pass an existing element instead, patchdom will patch that element (attempting to recycle any existing markup), instead of using it as a container like in the past.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python 3.x - Monkey patch parent of class - Stack Overflow
Variables are references to objects. When you reassign a variable, it doesn't affect the previous object unless its reference count goes to ...
Read more >
Tips for Patch Compliance - Prevent Blindness North Carolina
Consider having a rule that only parents touch (put on, take off) the patch (e.g., “When the patch is on, only Mom or...
Read more >
Why is compliance with occlusion therapy for amblyopia so ...
To explore parents' perceptions and experiences of occlusion (patching) therapy for treatment of amblyopia in children.
Read more >
git-format-patch Documentation - Git
The "patch", which is the "diff -p --stat" output (see git-diff[1]) between the commit and its parent. The log message and the patch...
Read more >
quilt(1) - Linux manual page - man7.org
When quilt adds, removes, or renames patches, it automatically updates the ... -z Write to standard output the changes that have been made ......
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