Permalink
Browse files

fix(navbar-brand): Refactored component logic (#759)

  • Loading branch information...
tmorehouse committed Aug 1, 2017
1 parent 028eb5f commit c752fc83c367a63e0c573ddc716ac58096d86a29
Showing with 11 additions and 8 deletions.
  1. +11 −8 lib/components/navbar-brand.vue
@@ -1,11 +1,8 @@
<template>
<b-link v-if="isLink"
<component :is="componentTag"
class="navbar-brand"
v-bind="linkProps"
@click="$emit('click', $event)">
<slot></slot>
</b-link>
<component v-else :is="tag" class="navbar-brand">
v-bind="conditionalLinkProps"
@click="this.$emit('click', $event)">
<slot></slot>
</component>
</template>
@@ -22,7 +19,7 @@ import { assign } from '../utils/object';
const linkProps = assign(omitLinkProps('href', 'to', 'tag'), {
href: { type: originalLinkProps.href.type },
to: { type: originalLinkProps.to.type },
tag: { type: String, default: 'div' }
tag: { type: String }
});
export default {
@@ -31,7 +28,13 @@ export default {
computed: {
linkProps: computed.linkProps,
isLink() {
return this.to || this.href;
return this.to || this.href;
},
componentTag(){
return this.isLink ? `b-link` : (this.tag || 'div');
},
conditionalLinkProps() {
return this.isLink ? this.linkProps : {};
}
}
};

0 comments on commit c752fc8

Please sign in to comment.