Replies: 2 comments 1 reply
-
In fact, you only need to skip the You can make a mark and deal with it temporarily. bug I don’t think this handler is good, so i didn’t mention PR. // src/directives/if.ts
while ((elseEl = el.nextElementSibling)) { //...
const hasElse = checkAttr(elseEl, 'v-else') !== null
if (hasElse) {
// @ts-ignore
elseEl._else = true
}
const hasElseif = checkAttr(elseEl, 'v-else-if') !== null
if (hasElseif) {
// @ts-ignore
elseEl._elseif = true
}
} And skip it while walk // src/walk.ts
// @ts-ignore
if (el._else || el._elseif) {
return
} |
Beta Was this translation helpful? Give feedback.
1 reply
-
Well, you are using the variable |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Example: Components with Template and switch
v-if
is a specialdir
. The priority ofv-if
is higher than otherdir
such asv-scope
. Whenv-if
is switched, it generates anon-root block
and does not delete thedir
attributes on the original element (except forv-if
related), because it is clone logic(cloneNode
), butv-else
orv-else-if
are not so lucky. In addition to being collected when processingv-if
. They will also be processed asroot v-scope
. So the template It is used directly instead of cloning. This element can be rendered normally for the first time (if the condition is true), but because it is not a cloning logic, alldir
attributes have been removed. When thev-if
is switched to this element, will be regenerated non-root block, but because thedir
attributes of this element itself has been deleted, nodir
will be processed. for example If there is an event binding, it will not take effect.The reason for this problem is the logical conflict between
v-if
androot v-scope
, as long asv-if
does not appear on theroot v-scope
, there is no problem.If this scenario is reasonable. Then we should resolve this conflict internally. One of my thoughts is to mark
v-else
orv-else-if
when dealing withv-if
, and then process theblock
generation. In fact, I feel that this method is not very appropriate, but I didn't think of a better wayBeta Was this translation helpful? Give feedback.
All reactions