-
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: (27 commits) 1.0.0-beta.4 chores changed build script to work around cross-env improved examples, added router to split things up nicely fix example index.js for production run new test build bumping dependencies caused troubles with dependency svgo fix dockute dependency and nom script add $refs test to the examples add section about $refs caveat from #23 to docs chores clean up npm scripts, include test run in build script remove unnecessary folder add „Caveats“ page to docs add test for abstract component option Document SSR limitations when using „targetEl“ make „to“ optional when targetEl is provided (fix #30) add reference to parent component (fix #34) (fix#35) (+1 squashed commit) Squashed commits: [770211d] enhance `targetEl` example with test component to verify that it shows up in devtools correctly. switch to nextTick instead of timeout in hopes of making refs work ...
- Loading branch information
Showing
35 changed files
with
489 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ docs/ | |
build/ | ||
example/ | ||
test/ | ||
|
||
logo.xcf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#Known Caveats | ||
|
||
Admittedly, portal-vue does a little bit of trickery to do what it does. With this come some caveats, which are documented below. | ||
|
||
## Abstract components | ||
|
||
`Portal` and `PortalTarget` are abstract components, which was necessary to make `$parent` work in the slot content as if the portal | ||
did not exist, and keep pointing to the parent component of the portal. | ||
|
||
That means they behave a bit differently in two ways: | ||
|
||
1. They don't show up in devtools. | ||
2. they don't show up in `$children` | ||
|
||
## Server-Side Rendering | ||
|
||
When you Vue [Vue's SSR capabilities](https://ssr.vuejs.org), there are some restrictions as well: | ||
|
||
1. Order of components | ||
|
||
The `PortalTarget` has to appear **after** the **Portal** component in the document flow. | ||
The reason is that Vue renders the result of the first render to a string immediatly - so any changes that are triggered in a `PortalTarget` | ||
after it has been initially rendered will not appear in the HTML document that is sent to the user's browser - but they will appear after hydration, | ||
which will make Vue bail the hydration phase because it didn't find the HTML that it expected, and re-render the whole app. | ||
|
||
2. targetEl cannot be a real HTMLElement | ||
|
||
See the <a href="#" router-link="/docs/portal#targetel">Portal</a> documentation for details | ||
|
||
## Refs | ||
|
||
The internal mechanism which sends updates from `Portals` to `PortalTargets` is asynchrnoues at the moment, to avoid some race conditions. | ||
|
||
Unfortunately, this means that `$refs` that you might have added to a `Portal's` slot content will not be available on the next Tick, but only the one after that. | ||
|
||
So you have to use a workaround for now: | ||
```javascript | ||
// Option 1: Two nested $nextTick calls | ||
this.$nextTick(() => { | ||
this.$nextTick(() => { | ||
console.log(this.$refs.text) | ||
}) | ||
}) | ||
|
||
// Option 2: setTimeout | ||
setTimeout(() => { | ||
console.log(this.$refs.text) | ||
}, 0) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,45 @@ | ||
<template> | ||
<div> | ||
|
||
<toggle-example /> | ||
|
||
<target-switch /> | ||
|
||
<source-switch /> | ||
|
||
<disabled /> | ||
|
||
<comp-as-root /> | ||
|
||
<empty-portal /> | ||
|
||
<mount-to-external /> | ||
<div class="main-container"> | ||
<div class="sidebar"> | ||
<ul> | ||
<li v-for="target in routes"> | ||
<router-link :to="target.path"> {{target.path}}</router-link> | ||
</li> | ||
</ul> | ||
</div> | ||
<div class="viewport"> | ||
<router-view /> | ||
</div> | ||
</div> | ||
|
||
</template> | ||
|
||
<script> | ||
import ToggleExample from './toggle/toggle-example.vue' | ||
import TargetSwitch from './target-switch/target-switch.vue' | ||
import SourceSwitch from './source-switch/source-switch.vue' | ||
import Disabled from './disabled' | ||
import CompAsRoot from './comp-as-root/comp-as-root.vue' | ||
import MountToExternal from './mount-to/mount-to-external.vue' | ||
import EmptyPortal from './empty-portal/index.vue' | ||
import { routes } from '../router' | ||
export default { | ||
components: { | ||
ToggleExample, | ||
TargetSwitch, | ||
SourceSwitch, | ||
Disabled, | ||
CompAsRoot, | ||
MountToExternal, | ||
EmptyPortal, | ||
name: 'App', | ||
created () { | ||
this.routes = routes | ||
}, | ||
} | ||
</script> | ||
|
||
<style> | ||
<style lang="scss"> | ||
@import '../styles/variables'; | ||
.main-container { | ||
display: flex; | ||
height: 100vh; | ||
} | ||
.sidebar { | ||
padding: 10px; | ||
flex: 0 0 300px; | ||
border-right: 3px solid $vueColor; | ||
} | ||
.viewport { | ||
flex: 1 1 auto; | ||
padding: 25px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.