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

transfer DOM #2130

Closed
rhyzx opened this issue Jan 8, 2016 · 6 comments
Closed

transfer DOM #2130

rhyzx opened this issue Jan 8, 2016 · 6 comments

Comments

@rhyzx
Copy link

rhyzx commented Jan 8, 2016

We may need DOM place in some other location in some situations, eg: place <modal> in root element(body).

position: fixed is not a perfect solution, when inside parent with z-index, it may be overlap by other elements: http://stackoverflow.com/a/16756277

I made some experiments and it seems impossible to achieve this by custom directive, so i made some modifications in source code and it works as expected:
http://jsfiddle.net/rhyzx/s3L0emxy/

commit is here: rhyzx@8430843

How do you think about this feature? @yyx990803

@yyx990803
Copy link
Member

Thanks for the suggestion! This is definitely useful, however my concern is:

  1. The rendered DOM structure would be different from the template structure;
  2. The use case is a bit narrow for a new core directive: it is only necessary when we don't have control over the z-index of our app element on the page.

@rhyzx
Copy link
Author

rhyzx commented Jan 9, 2016

  1. The rendered DOM structure would be different from the template structure;
  2. The use case is a bit narrow for a new core directive: it is only necessary when we don't have control over the z-index of our app element on the page.

That's true. this is a edge case and seems no perfect way to solve, eg. bootstrap's solution: http://v4-alpha.getbootstrap.com/components/modal/#live-demo , by this way, modal's lifecycle is not inherit from parent and not context aware. ng's solution is little cumbersome: https://angular-ui.github.io/bootstrap/#/modal .

How about providing some ways(may be an API) to extending this feature?

@yyx990803
Copy link
Member

Yeah, it definitely should be extendable... I think the only thing preventing it is the internal terminalDirectives array, since both util and FragmentFactory are exposed already.

@yyx990803
Copy link
Member

So, with be0d1cd75b4d84ece2b97cac5701376070884ab2 you should have everything you need to implement v-inject as a third party directive:

  • Vue.FragmentFactory
  • Vue.util
  • Vue.compiler.terminalDirectives

I'll close this now - feel free to share v-inject and add it to awesome-vue :)

@rhyzx
Copy link
Author

rhyzx commented Jan 10, 2016

Great, thanks.

@geraldlrh
Copy link

how vue2.0 to transfer dom like this?

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

No branches or pull requests

3 participants