Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Vugel we noticed that when using a template ref
<container ref="test" />
and then use theref
function rather thanshallowRef
function:We get a proxy to the node.
When invoking any method on
test
, the proxyfication of it causes the JIT optimizer to deopt functions, leading to performance problems. This problem doesn't really occur in vue dom itself, but it does affect all javascript-based custom renderers.We'd like developers to always use shallowRef for template refs to avoid these problems, so we'd like to disable reactivity. Judging by the source code it can be fixed by marking every node as raw using
markAsRaw
, but that would affect performance. Internally_isVNode
and_isVue
are used for a similar reason._isVue
doesn't seem to be set anywhere, so I guess it's old and should be removed?! For our own use case this PR adds the_notReactive
flag. We can simply set it on our prototype.By the way, the Composition API describes how to use template refs. Shouldn't it use
shallowRef
rather thanref
? It doesn't seem to make sense to make all (HTML) element attributes reactive? The typical use case is that a developer wants to get a reference to the template.