Skip to content

Commit

Permalink
Wrap element in $ for Element#cumulativeOffset, #viewportOffset, …
Browse files Browse the repository at this point in the history
…#positionedOffset, and #getOffsetParent. [#782 state:resolved] (Radoslav Stankov, Andrew Dupont)
  • Loading branch information
savetheclocktower committed Oct 17, 2010
1 parent 34564c5 commit 46d273e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,3 +1,5 @@
* Wrap `element` in `$` for Element#cumulativeOffset, #viewportOffset, #positionedOffset, and #getOffsetParent. [#782 state:resolved] (Radoslav Stankov, Andrew Dupont)

*1.7_rc3* (October 11, 2010)

* Feature detect IE's legacy event system, since IE9 now supports DOM L2 Events. (Michael Sciacqua, kangax, Andrew Dupont)
Expand Down
6 changes: 6 additions & 0 deletions src/dom/layout.js
Expand Up @@ -849,6 +849,7 @@
* `body` element is returned.
**/
function getOffsetParent(element) {
element = $(element);
if (isDetached(element)) return $(document.body);

// IE reports offset parent incorrectly for inline elements.
Expand All @@ -873,6 +874,7 @@
* document.
**/
function cumulativeOffset(element) {
element = $(element);
var valueT = 0, valueL = 0;
if (element.parentNode) {
do {
Expand All @@ -891,6 +893,8 @@
* (the element that would be returned by [[Element.getOffsetParent]]).
**/
function positionedOffset(element) {
element = $(element);

// Account for the margin of the element.
var layout = element.getLayout();

Expand Down Expand Up @@ -934,6 +938,7 @@
* Returns the X/Y coordinates of element relative to the viewport.
**/
function viewportOffset(forElement) {
element = $(element);
var valueT = 0, valueL = 0, docBody = document.body;

var element = forElement;
Expand Down Expand Up @@ -1059,6 +1064,7 @@
// positioned. For performance reasons, redefine Element#cumulativeOffset for
// KHTML/WebKit only.
cumulativeOffset = function(element) {
element = $(element);
var valueT = 0, valueL = 0;
do {
valueT += element.offsetTop || 0;
Expand Down

0 comments on commit 46d273e

Please sign in to comment.