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
feat(useParentElement): new function #2855
Conversation
BTW, I am wondering if it's possible to aware that a <div id="container1">
<div id="target"></div>
</div>
<div id="container2">
<!-- move #target here -->
</div>
<script>
const container2 = document.querySelector('#container2')
const target = document.querySelector('#target')
// move #target to #container2
container2.appendChild(target)
</script> I think maybe MutationObserver would work. |
return { | ||
parentElement, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return { | |
parentElement, | |
} | |
return parentElement |
Do you foresee any other things to return in the future?
import { getCurrentInstance, ref } from 'vue-demi' | ||
import { unrefElement } from '../unrefElement' | ||
|
||
export const useParentElement = (element?: MaybeComputedRef<HTMLElement | SVGElement | null | undefined>) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use function
on top-level
Sorry team, I was busy lately and couldn't update the PR. Thanks, Anthony for the updates 🙏🏻 |
Description
This function allows getting the parent element of the current element or passed
ref
.Additional context
Porting
useParentElement
from Anu to VueUse as discussed here: #2814What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).