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

Implementation of portals #2147

Merged
merged 5 commits into from
Nov 16, 2021
Merged

Implementation of portals #2147

merged 5 commits into from
Nov 16, 2021

Conversation

WorldSEnder
Copy link
Member

@WorldSEnder WorldSEnder commented Nov 15, 2021

Description

Portals, as provided in React with React.createPortal, are a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.

There are two major properties an implementation should have.

  1. An arbitrary, third-party element can be used to mount a subtree of the virtual dom.
  2. Event bubbling (and moving the exit of the portal) should respect (and preserve) the virtual dom.

This POC contains the primitive VNode::VPortal and VPortal::create to implement components that for example mount their children into an iframe (have to wait for the document to be ready), or to attach a shadow dom to an element. Yet, the implementation as components is not contained in this PR. Not sure where this part belongs, actually, probably in third-party libs or utils.

Fixes #1992

Checklist

  • I have run cargo make pr-flow
  • I have reviewed my own code
  • I have added tests

PS: I'm running cargo make pr-flow and getting erros comparing compile-errs in yew-macro/tests/html_macro, everything else works, including the tests in this PR. Can someone tell me what I might be doing wrong? After running cargo update, this also works locally.

@voidpumpkin voidpumpkin added the A-yew Area: The main yew crate label Nov 15, 2021
@WorldSEnder WorldSEnder marked this pull request as ready for review November 16, 2021 01:42
@WorldSEnder WorldSEnder changed the title POC implementation of portals Implementation of portals Nov 16, 2021
@github-actions
Copy link

Visit the preview URL for this PR (updated for commit 97627fe):

https://yew-rs--pr2147-portals-qy10bsl6.web.app

(expires Tue, 23 Nov 2021 08:32:42 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Copy link
Member

@voidpumpkin voidpumpkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing contribution, thank you!

@voidpumpkin voidpumpkin enabled auto-merge (squash) November 16, 2021 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-examples Area: The examples A-yew Area: The main yew crate documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants