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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Example: Components with Template and switch
v-ifis a specialdir. The priority ofv-ifis higher than otherdirsuch asv-scope. Whenv-ifis switched, it generates anon-root blockand does not delete thedirattributes on the original element (except forv-ifrelated), because it is clone logic(cloneNode), butv-elseorv-else-ifare 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, alldirattributes have been removed. When thev-ifis switched to this element, will be regenerated non-root block, but because thedirattributes of this element itself has been deleted, nodirwill 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-ifandroot v-scope, as long asv-ifdoes 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-elseorv-else-ifwhen dealing withv-if, and then process theblockgeneration. 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