From ea9d81eea15a4f6d8675bdff09751e6da701d56e Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Sun, 3 Feb 2008 19:36:35 +0000 Subject: [PATCH] prototype: Make Element#absolutize and Element#relativize always return element. Closes #10983. --- CHANGELOG | 2 ++ src/dom.js | 4 ++-- test/unit/dom.html | 9 +++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e5c087c..2b2addb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Make Element#absolutize and Element#relativize always return element. Closes #10983. [kangax] + * Add deprecation extension. [Tobie Langel] *1.6.0.2* (January 25, 2008) diff --git a/src/dom.js b/src/dom.js index 2a2be6f..6b44eed 100644 --- a/src/dom.js +++ b/src/dom.js @@ -527,7 +527,7 @@ Element.Methods = { absolutize: function(element) { element = $(element); - if (element.getStyle('position') == 'absolute') return; + if (element.getStyle('position') == 'absolute') return element; // Position.prepare(); // To be done manually by Scripty when it needs it. var offsets = element.positionedOffset(); @@ -551,7 +551,7 @@ Element.Methods = { relativize: function(element) { element = $(element); - if (element.getStyle('position') == 'relative') return; + if (element.getStyle('position') == 'relative') return element; // Position.prepare(); // To be done manually by Scripty when it needs it. element.style.position = 'relative'; diff --git a/test/unit/dom.html b/test/unit/dom.html index e268a37..c72face 100644 --- a/test/unit/dom.html +++ b/test/unit/dom.html @@ -1644,6 +1644,15 @@ elt.absolutize(); assertUndefined(elt._originalLeft, 'absolutize() did not detect absolute positioning'); }); + // invoking on "absolute" positioned element should return element + var element = $('absolute_fixed_undefined').setStyle({position: 'absolute'}); + assertEqual(element, element.absolutize()); + }}, + + testRelativize: function() {with(this) { + // invoking on "relative" positioned element should return element + var element = $('absolute_fixed_undefined').setStyle({position: 'relative'}); + assertEqual(element, element.relativize()); }}, testViewportDimensions: function() {with(this) {