0

When applying document.elementFromPoint on point(x,y) which points to an element somewhere inside a documentFragment, it returns the container element. For example:

<div id="container">
     <div id="my_documentfragment">
         <span> something </span>
     </div>
</div>

Expected Result: If (x,y) are pointing to #my_documentfragment, document.elementFromPoint(x,y) it should return #my_documentfragment.

Actual Result: returns #container. the container of the document fragment

  1. What's the alternative to document.elementFromPoint(x,y) when some parts of the page are documentFragments?
  2. What's the alternative to jquery.parents() on an element that is part of a documentFragment
Nizar
  • 481
  • 5
  • 8
  • `documentFragment` is by [definition](https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment) a dom object having no parent and not attached to active DOM tree, and when you insert the `fragment`, technically the children are moved and the `documentFragment` stays still detached, orphan, but empty. So I am not sure what is your question about. Could you clarify? – Karen Grigoryan Feb 24 '19 at 15:43
  • Thanks Karen. What's the alternative to document.elementFromPoint(x,y) when some parts of the page are documentFragments? – Nizar Mar 05 '19 at 15:10
  • @KarenGrigoryan – Nizar Mar 19 '19 at 12:27
  • `documentFragment`s cannot be part of the page, that's the whole point, they are a mechanism to group detached dom nodes and insert them efficiently without reflow into the active document. They assist inserting, but they are not inserted with the nodes themselves. They never become part of the active document, thus you cannot track their position, because they don't exist in the render space. They float around in the heap until getting garbage collected after being used. Let me know if this explanation is clearer. – Karen Grigoryan Mar 19 '19 at 13:55
  • This was clear even before I asked this question, In this question I'm looking for alternatives to the two use cases I presented. – Nizar Apr 07 '19 at 16:50

0 Answers0