Add Element#cloneDimensions. Fix clonePosition, viewportOffset, getOffsetParent and make sure Element#getDimensions works with display:none ancestors.
Reported by Nick Stakenburg | April 14th, 2008 @ 12:06 PM | in 1.6.1
The dimensions part in Element#clonePosition doesn't work correctly, I figured it could be useful so I've fixed it up. I've added Element#cloneDimensions. Since clonePosition is also trying to clone dimensions it makes sense to have that available as well, it's also better named.
Since I like getting expected results I made sure Element#getDimensions always returns the right dimensions, even when the element has display: none ancestors. Besides that this is extremely useful it also helps when you are trying to clone something that's hidden.
Unit tests are added for Element#clonePosition, Element#cloneDimensions and Element#getDimensions and I've fixes a few bugs while testing, I'll describe those:
When Element#getOffsetParent attempts to call Element.getStyle on the document node, IE will throw: 'style' is not available.
Element#viewportOffset fails on Opera 9.5. Hallvord R. M. Steen (Opera.com) emailed me after he found a testpage I did on this and came up with a fix: 10486
Comments and changes to this ticket
-
Andrew Dupont April 14th, 2008 @ 03:59 PM
- → State changed from new to open
Thanks, Nick. I'll compare this to the broad dimensions overhaul we're planning for 1.6.1. Feel free to fork and experiment.
-
John-David Dalton April 15th, 2008 @ 01:55 AM
Patch and Tests for the offsetParent and viewportOffset errors here as well (makes offsetParent return body and not document.documentElement):
-
John-David Dalton April 15th, 2008 @ 01:59 AM
The patches at the link I posted are not for the Opera 9.5 error, but for an IE related issue.
-
Tobie Langel April 16th, 2008 @ 07:58 PM
- → State changed from open to enhancement_patch
- → Milestone changed from to 1.6.1
-
Tobie Langel April 18th, 2008 @ 11:21 AM
- → Title changed from [PATCH] [TEST] Add Element#cloneDimensions. Fix clonePosition, viewportOffset, getOffsetParent and make sure Element#getDimensions works with display:none ancestors. to Add Element#cloneDimensions. Fix clonePosition, viewportOffset, getOffsetParent and make sure Element#getDimensions works with display:none ancestors.
- → State changed from enhancement_patch to enhancement
-
Andrew Dupont April 20th, 2008 @ 10:08 PM
- → Assigned user changed from to Andrew Dupont
-
Juriy Zaytsev April 20th, 2008 @ 10:11 PM
I would vote for Element#visible to work with "display:none" ancestors as well. Using optional [deep=false] attribute should not affect current implementation (speed/compatibility)
-
Andrew Dupont April 21st, 2008 @ 03:22 AM
I've checked in this fix on my branch: http://github.com/savetheclockto...
Nick, I left out your
cloneDimensionsmethod because it overlaps with what we're already doing with the dimensions overhaul. The rest of your fixes were added, though, as were the corresponding tests.This ticket will be closed once my branch gets merged back into Sam's. Thanks!
-
Nick Stakenburg April 21st, 2008 @ 11:04 AM
Thanks Andrew. The dimensions overhaul looks great, can't wait for 1.6.1.
+1 for Element#visible to also work with display:none.
-
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
The Prototype JavaScript library.
