fix(devtools-kit): only treat own render property as component definition#1110
fix(devtools-kit): only treat own render property as component definition#1110lazerg wants to merge 3 commits into
Conversation
✅ Deploy Preview for vue-devtools-docs canceled.
|
|
@skirtles-code you'd already pinpointed the line on this one, mind checking if the own-property guard matches what you had in mind? |
skirtles-code
left a comment
There was a problem hiding this comment.
I didn't really have a specific fix in mind when I posted that comment.
There is no totally reliable way to detect a component, but using hasOwnProperty is an interesting idea. Components can, in theory, inherit a render property via their prototype chain, but I'm not sure whether that's common enough to worry about.
One thought that occurs is that components are plain (non-reactive) objects, so I wonder whether we can take advantage of that to improve the detection heuristics?
|
took a look at how I can't completely rule out some old class-component library doing it differently, but that's rare enough in current Vue 3 code that it's not worth designing around. The reactive vs. plain object idea is a good one. There's already an I can add that as an extra condition next to the |
|
Yeah, I think adding an |
|
Added the |
Fixes #1100.
As @skirtles-code pointed out in the issue, the state serializer treats any object with a
rendermethod as a Vue component definition, so plain class instances stored in Pinia state (whose class happens to define arendermethod) are shown as "Unknown component". A component definition keepsrenderas an own property, whereas a class instance inherits it from the prototype, so this checks for an ownrenderproperty — real component definitions are still detected, and ordinary objects are left alone.