Skip to content

Commit

Permalink
fix(navbar-brand): Refactored component logic (#759)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmorehouse committed Aug 1, 2017
1 parent 028eb5f commit c752fc8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions 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>
Expand All @@ -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 {
Expand All @@ -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 : {};
}
}
};
Expand Down

0 comments on commit c752fc8

Please sign in to comment.