Skip to content
This repository was archived by the owner on Aug 18, 2023. It is now read-only.

[Question] How do you handle marks with empty text? #12

Open
mornir opened this issue Jul 19, 2020 · 0 comments
Open

[Question] How do you handle marks with empty text? #12

mornir opened this issue Jul 19, 2020 · 0 comments

Comments

@mornir
Copy link
Contributor

mornir commented Jul 19, 2020

Hi!
By accident and without realizing it, one of my client added a mark (internal link) to an empty space, resulting in a empty and, in my case, invisible <a href="/about"></a> on the front-end. However it is still focusable when tabbing.

Ideally, I don't want that link to be rendered at all. I was able to solve the problem with functional template components by checking for children[0] && children[0].text. Example:

<template functional>
  <nuxt-link
    v-if="props.slug && children[0] && children[0].text"
    :to="props.slug + '/'"
    class="underline"
  >
    <slot />
  </nuxt-link>
</template>

However, for normal vue components, I only found convoluted ways and not clean and easy ways to check for empty slot. From what I understood "this.$slots.default[0]" is "false" at first and then "true", but it can't be track in a computed property because it's not reactive.

I was thinking, maybe we could add an option to this library for automatically hiding marks with empty text property?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant