prototype: Make Element#absolutize and Element#relativize always return element. Closes #10983.

This commit is contained in:
Tobie Langel 2008-02-03 19:36:35 +00:00
parent ed1469396e
commit ea9d81eea1
3 changed files with 13 additions and 2 deletions

View File

@ -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)

View File

@ -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';

View File

@ -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) {