Re: [webcomponents] Adjusting offsetParent, offsetTop, offsetLeft properties in Shadow DOM

On Wed, Mar 27, 2013 at 2:02 PM, Boris Zbarsky <> wrote:

> Scott Miles wrote:
> > This is a thorny problem, but my initial reaction is that you
> > threaded the needle appropriately. I don't see how we avoid some
> > lossiness in this situation.
> Note that if you're using offsetWith/Height/Top/Bottom you already lose,
> because they return integers.
> I think we should be doing what we can to discourage use of these broken
> APIs, for what it's worth, instead of worrying how we can extend their
> already-incorrect behavior to cover more cases "well".

That's fair, how do you feel about getPositionedAncestor(bool
includingTraversableShadows) ? This would solve the primary use cases for
offsetParent, and also mean jQuery wouldn't need to call getComputedStyle
all the way up the tree.

Walking the box tree is super fast in C++, and isPositioned is a bitfield
check. Doing this in JS with getComputedStyle is quite a lot more expensive
(allocate CSSComputedStyleDeclaration, parse the property name, return the
position value, compare the string).

- E

Received on Thursday, 28 March 2013 16:56:28 UTC