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.

There is no way to patch element with id and classes without replacing it

See original GitHub issue

There is no way to patch already existing element with classes and id, if root vnode also has id or classes.

var elm = document.createElement('div');
elm.setAttribute('id', 'testid');

var vnode = h('div#testid', 'testtext');
patch(elm, vnode);

console.log(elm === vnode.elm); // false
console.log(elm.innerText); // ''
console.log(vnode.elm.innerText); // 'testtext'

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
paldepindcommented, Jul 24, 2016

Yes. The classes and id’s inside the selector are static. This has advantage that Snabbdom can use this static information exactly to determine if an element should be replaced. This makes using key unnecessary in many cases.

0reactions
grimalschicommented, Jul 23, 2016

Ok, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change the element with no ID in jquery?
You can actually search for spans based on their contents if that is the only way you have of identifying them.
Read more >
The Difference Between ID and Class | CSS-Tricks
There is nothing stopping you from having both an ID and a Class on a single element. In fact, it is often a...
Read more >
Type, class, and ID selectors - Learn web development | MDN
A type selector is sometimes referred to as a tag name selector or element selector because it selects an HTML tag/element in your...
Read more >
Selectors - W3C
A simple selector is either a type selector or universal selector followed immediately by zero or more attribute selectors, ID selectors, or pseudo-classes,...
Read more >
Lesson 1: Understanding ID and Class in CSS
In this lesson you will learn how ID and Class attributes can be used to ... there's no other element - paragraph 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