Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: renderCustomElements is not bullet-proof #280

Merged
merged 7 commits into from
Dec 26, 2024

Conversation

fago
Copy link
Contributor

@fago fago commented Dec 22, 2024

When trying to improve our default node component to use the proper slot syntax (as documented) I ran into problems with rendering custom elements erroring out.. Let's fix this by making the helper real-bullet-proof and properly documented.

It should work like this

    <slot name="image"> 
      <component :is="useDrupalCe().renderCustomElements($attrs.image)" />
    </slot>
    <slot name="body">
      <component :is="useDrupalCe().renderCustomElements($attrs.body)" />
    </slot>

However, it dies if

  • the value is null, what could be fixed with a v-if but even nicer/shorter/better to have it not die and return null
  • the slot is output not as a object but a simple string. apparently this happens for the body/image.

Current work-a-roudn is really not nice and not what we want to keep:

    <slot name="image"> 
      <component v-if="$attrs.image" :is="useDrupalCe().renderCustomElements({
        element: $attrs.image.element ?? 'drupal-markup',
        content: $attrs.image,
      })" />
    </slot>

Let's fix this, so renderCustomElements can be used without hassle / lots of needs the passed data is an object.

@fago fago force-pushed the feature/fix-renderCustomElements branch 2 times, most recently from 0c9cd84 to 0612c7a Compare December 22, 2024 05:38
@fago fago force-pushed the feature/fix-renderCustomElements branch from 0612c7a to 25f5e00 Compare December 22, 2024 05:49
@fago fago merged commit ee5572b into 2.x Dec 26, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant