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

Add back Wormhole.hasContentFor #194

Closed
bbugh opened this issue Apr 11, 2019 · 2 comments · Fixed by #195
Closed

Add back Wormhole.hasContentFor #194

bbugh opened this issue Apr 11, 2019 · 2 comments · Fixed by #195
Milestone

Comments

@bbugh
Copy link

bbugh commented Apr 11, 2019

The Wormhole docs say hasContentFor will let me check if a portal has content. TypeScript is reporting that this method doesn't exist or isn't exported. It seems like maybe it's not exported for TypeScript? This is really important for my use case, because I need to wrap the portal output in some styles.

Here's a simplified example of what I need. It's critical to our setup, and the reason I'm evaluating portal-vue is because slots and router-view are both failing in our scenario. portal-vue is perfect, except I need to know if content has been defined.

Here's a simplified example:

<!-- this shouldn't appear at all if there's no content because it breaks the page layout -->
<div v-if="hasSidebarPortalContent">
  <div class="something for responsive">
    <portal-target name="sidebar" /> 
  </div>
</div>
computed () {
  hasSidebarPortalContent () {
    return Wormhole.hasContentFor('sidebar')
  }
}

Is this just missing from the type export or is there some different way to do this?

@LinusBorg
Copy link
Owner

😩

That's one of the few APIs I dropped for 2.0 since I never came across anyone using them. Which is why you won't find them in the docs for 2.0 on portal-vue.linusb.org. Did you look at old docs perhaps?

I can consider adding it back in, now that I have finally seen a use case for it. 😅

But might take a few days.

As a workaround, you could use this for now:

return !!Wormhole.transports[sidebar].length

Wormhole.transports is not strictly public API but won't change in this major, I can promise that.

@LinusBorg LinusBorg changed the title Not finding Wormhole.hasContentFor from docs Add back Wormhole.hasContentFor Apr 11, 2019
@LinusBorg LinusBorg added this to the 2.1 milestone Apr 11, 2019
@bbugh
Copy link
Author

bbugh commented Apr 12, 2019

Haha, oh no! I see now that you just removed it a few days ago. I hadn't seen the 2.0 upgrading guide until searching google for the method name. I'm surprised this hasn't come up before! Wrapping things like this in some kind of containers seems like a common use case to me. Thank you for the quick response and the re-add, and the workaround until 2.1 is released. (and all the hard work)

LinusBorg added a commit that referenced this issue Apr 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants