Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11319 (closed defect: duplicate)

Opened 6 months ago

Last modified 5 months ago

[PATCH]Incorrect getOffsetParent for newly inserted inserted elements on body (IE6)

Reported by: rubyruy Assigned to: sam
Priority: normal Milestone: 2.x
Component: Prototype Version: edge
Severity: normal Keywords: dom ie6
Cc:

Description

Very easy to illustrate:

      var newElement = new Element("div");
      $(document.body).insert(newElement);
      assertEqual(document.body, newElement.getOffsetParent()) // fails in IE6 - it returns the HTML element instead

This causes all sorts of really fun to track down problems down the road.

The fix is pretty straight forward - the only odd part is that element.offsetParent will actually return the correct BODY element up until element.setStyle({ position: 'relative' }); is called (inside the IE-specific wrap for getOffsetParent). Something about relativizing the element causes it to have its offsetParent property to the HTML element instead.

Attachments

test_for_offset_parent_on_new_body_elements.diff (0.9 kB) - added by rubyruy on 03/11/08 02:48:10.
test_for_offset_parent_on_new_body_elements.2.diff (0.6 kB) - added by rubyruy on 03/11/08 02:49:43.
patch_for_offset_parent_on_new_body_elements.diff (0.5 kB) - added by rubyruy on 03/11/08 02:50:34.

Change History

03/11/08 02:48:10 changed by rubyruy

  • attachment test_for_offset_parent_on_new_body_elements.diff added.

03/11/08 02:49:43 changed by rubyruy

  • attachment test_for_offset_parent_on_new_body_elements.2.diff added.

03/11/08 02:50:34 changed by rubyruy

  • attachment patch_for_offset_parent_on_new_body_elements.diff added.

03/11/08 02:51:04 changed by rubyruy

forgot to check the little box - ignore first test_* attachment please.

04/09/08 01:08:33 changed by jdalton

  • status changed from new to closed.
  • resolution set to duplicate.

dup of #11473