utils/dom/getoverlaymountroot
module
Functions
getOverlayMountRoot( containerNode ) → ShadowRoot | HTMLElement | nullmodule:utils/dom/getoverlaymountroot~getOverlayMountRootReturns the DOM tree that a feature's floating UI – its balloons, dialogs and tooltips – should be put in: the same one the feature itself is in.
Floating UI would otherwise go into
document.body. That is outside the shadow root an editor may live in, so the UI would leave the tree the editor's styles were loaded into, and lose them.Being in the same tree means one of three things:
- the shadow root the given element is in, if it is in one. A shadow root passed in returns itself.
- the
<body>of that element's own document otherwise, so an editor in an iframe stays in that iframe. nullwhile the element is detached, because there is no telling yet which tree it will end up in. Put the UI nowhere for now and ask again once the element is in the DOM.
Feed the result to
syncMountTarget, and call this again whenever the element may have moved. Works with open and closed shadow roots.Parameters
containerNode: Element | ShadowRootThe element the floating UI belongs to – usually the feature's container.
Returns
ShadowRoot | HTMLElement | null