-
-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(no-deprecated-slot-attribute): handle v-for with dynamic slot #2529
fix(no-deprecated-slot-attribute): handle v-for with dynamic slot #2529
Conversation
const vForText = vFor ? `${sourceCode.getText(vFor)} ` : '' | ||
if (vFor) { | ||
yield fixer.remove(vFor) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also considered the case for v-if
—would an empty template
still cause the parent to think it received an empty slot?
But I confirmed in Vue 2 that these are identical in terms of the parent's this.$slots
:
<Parent>
<div v-if="false" slot="name">
slot value
</div>
<template slot="name">
<div v-if="false">
slot value
</div>
</template>
</Parent>
const slotName = sourceCode.getText(slotAttr.value.expression).trim() | ||
// If non-Latin characters are included it can not be converted. | ||
// It does not check the space only because `a>b?c:d` should be rejected. | ||
return !/[^a-z]/i.test(slotName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was confused about why it's doing this.
I felt like we just want to confirm it's a single Identifier so I went ahead and changed it and it didn't seem to break any tests, but I'm happy to revert this if we want to keep the scope small.
139bf0b
to
6f24c45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks for your contribution!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!
Fixes an edge-case where the slot is dynamic derived from a
v-for
.Previously, it would move the
slot
directive in a new<template>
above thev-for
, which broke it.Now, it also moves the
v-for
to the new<template>
.