All files / lib/components navbar-brand.vue

58.82% Statements 10/17
33.33% Branches 6/18
57.14% Functions 4/7
58.82% Lines 10/17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 4218x 18x 18x   18x 18x                     18x       18x     18x                 18x                  
<template>
     <component :is="componentTag" 
    I         class="navbar-brand"
             v-bind="conditionalLinkProps"
           E  @click="this.$emit('click', $event)">
        <slot></slot>
    </component>
</template>
 
<script>
import bLink from './link.vue';
import { omitLinkProps, props as originalLinkProps, computed } from '../mixins/link';
import { assign } from '../utils/object';
 
// Grab a fresh object of link props (omitLinkProps does this)
// less the 'href', 'to', and 'tag' props
// that we will reconstruct without any defaults
// so our component functions properly
const linkProps = assign(omitLinkProps('href', 'to', 'tag'), {
    href: { type: originalLinkProps.href.type },
    to: { type: originalLinkProps.to.type },
    tag: { type: String }
});

export default {
    components: { bLink },
    props: linkProps,
    computed: {
        linkProps: computed.linkProps,
        isLink() {
            return this.to || this.href;
        },
        componentTag(){
            return this.isLink ? `b-link` : (this.tag || 'div');
        },
        conditionalLinkProps() {
            return this.isLink ? this.linkProps : {};
        }
    }
};
</script>