<script>
export default {
  props: ['href'],
  functional: false,
  methods: {
    scrollToHref() {
      document.querySelector(this.href).scrollIntoView({ behavior: 'smooth' });
    }
  },
  render(createElement) {
    const { $attrs, $listeners, $scopedSlots } = this;

    return createElement(
      'a',
      {
        attrs: $attrs,
        on: {
          click: event => {
            event.preventDefault();
            this.scrollToHref();
          },
          ...$listeners
        }
      },
      [$scopedSlots.default({})]
    );
  }
};
</script>
