fix(no-deprecated-slot-attribute): handle v-for with dynamic slot by privatenumber · Pull Request #2529 · vuejs/eslint-plugin-vue (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation4 Commits1 Checks11 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
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 the v-for
, which broke it.
Now, it also moves the v-for
to the new <template>
.
const vForText = vFor ? `${sourceCode.getText(vFor)} ` : '' |
---|
if (vFor) { |
yield fixer.remove(vFor) |
} |
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
:
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) |
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.
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!
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you!