Override jQuery.contains instead of jQuery.fn.position

Turns out the problems with position inside the shadow DOM are due to
the fact that elements in the light DOM don’t claim to contain elements
from a shadow DOM, causing jQuery.fn.offset to bail out early and
misreport positions inside the editor.
This commit is contained in:
Nathan Sobo
2014-10-20 17:03:16 -06:00
parent 5cc243ec11
commit 7863db480e

View File

@@ -78,10 +78,17 @@ jQuery.event.remove = (elem, types, originalHandler, selector, mappedTypes) ->
handler = HandlersByOriginalHandler.get(originalHandler) ? originalHandler
JQueryEventRemove(elem, types, handler, selector, mappedTypes, RemoveEventListener if atom?.commands?)
jQuery.fn.position = ->
top = @[0].offsetTop
left = @[0].offsetLeft
{top, left}
JQueryContains = jQuery.contains
jQuery.contains = (a, b) ->
shadowRoot = null
currentNode = b
while currentNode
if currentNode instanceof ShadowRoot and a.contains(currentNode.host)
return true
currentNode = currentNode.parentNode
JQueryContains.call(this, a, b)
tooltipDefaults =
delay: