-
Notifications
You must be signed in to change notification settings - Fork 10
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: BNavbar crash with "TypeError: this.$slots.brand is not a function" (#28) #30
Conversation
- Fixes the bug where an empty `BNavbar` crashed with "TypeError: this.$slots.brand is not a function". Checks if `this.$slots.brand` is not nullish before calling it. issue ntohq#28
src/components/navbar/Navbar.vue
Outdated
@@ -168,10 +168,16 @@ export default { | |||
]) | |||
}, | |||
genNavbarBrandNode() { | |||
let children |
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.
Semicolon?
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.
Does this look better?
const children = this.$slots.brand != null
? [this.$slots.brand(), this.genBurgerNode()]
: this.genBurgerNode()
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.
Yes that works ✨
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.
You can also add parentheses to make the conditional expression more clear in the ternary operation
const children = (this.$slots.brand != null)
? [this.$slots.brand(), this.genBurgerNode()]
: this.genBurgerNode()
src/components/navbar/Navbar.vue
Outdated
@@ -168,10 +168,16 @@ export default { | |||
]) | |||
}, | |||
genNavbarBrandNode() { | |||
let children |
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.
Yes that works ✨
src/components/navbar/Navbar.vue
Outdated
@@ -168,10 +168,16 @@ export default { | |||
]) | |||
}, | |||
genNavbarBrandNode() { | |||
let children |
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.
You can also add parentheses to make the conditional expression more clear in the ternary operation
const children = (this.$slots.brand != null)
? [this.$slots.brand(), this.genBurgerNode()]
: this.genBurgerNode()
- Regarding the conversation: ntohq#30 (comment)
@@ -168,10 +168,13 @@ export default { | |||
]) | |||
}, | |||
genNavbarBrandNode() { | |||
const children = this.$slots.brand != null | |||
? [this.$slots.brand(), this.genBurgerNode()] | |||
: this.genBurgerNode() |
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.
@wesdevpro I believe the updated code is legible enough and aligns with the style of the other part of the codebase.
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 ✨
@kikuomax please pull the changes into dev. For some reason I can't create a merge and commit. |
Fixes:
Proposed Changes
this.$slots.brand
is not nullish before calling it