For values returned from diff(), null === {}
See original GitHub issueThe code responsible for this is in vm.diff.cmp
. And it is executed during redrawSync()
.
Small test:
// Dummy vm for testing:
var vm = domvm.createView({render: function() {}});
vm.config({diff: function() {return 0;}});
// The comparison function that compares successive values returned by diff()
// doesn't differentiate between null and {}:
console.log("null === {}:", vm.diff.cmp(vm, null, {})); // => false
console.log("null === null:", vm.diff.cmp(vm, null, null)); // => false
// It is actually the same problem for any primitive value:
console.log("12 === 34:", vm.diff.cmp(vm, 12, 34)); // => false
console.log("12 === 12:", vm.diff.cmp(vm, 12, 12)); // => false
Issue Analytics
- State:
- Created 5 years ago
- Comments:29 (27 by maintainers)
Top Results From Across the Web
What are the error exit values for diff? - bash - Stack Overflow
It depends on your diff command. Mine (GNU diffutils 3.0) says: An exit status of 0 means no differences were found, 1 means...
Read more >4 Ways to Replace NULL with a Different Value in MySQL
The IFNULL() function allows you to provide two arguments. The first argument is returned only if it is not NULL. If it is...
Read more >sql server - Return NULL when distinct values else return value
I would like to find when two users have collected different surnames for the same name. The output I'm trying to get is:...
Read more >null - JavaScript - MDN Web Docs - Mozilla
The null value represents the intentional absence of any object value. It is one of JavaScript's primitive values and is treated as falsy...
Read more >Working with SQL NULL values - SQLShack
In the following query, the COALESCE() function returns the SQLShack.com because it is the first non-null value in the list.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well there is still a problem with eq(). For example:
This may happen because if one time you compare the old value
null
and the new value{}
, the next time{}
will be your old value, so the situation might be reversed.Here is a possible solution:
The idea is that if
o
andn
are not the same type, we returnfalse
. We need to take care of the special case where eithero
orn
isnull
. But we can actually skip theo !== null
because that will fallthrough the following tests and returnfalse
.kinda. for example, things like
new Date
andnew Promise
dont produce objects that are easily discernable without explicit checks, yet dont make sense to pass through cmpObj. also, cmpObj would iterate an instance’s public methods, etc.worst case for this “breaking” change is a perf regression, so i’m not too concerned.