Bug Tracker

Ticket #8150 (closed bug: fixed)

Opened 4 years ago

Last modified 3 years ago

removeAttr issue in webkit, firefox

Reported by: chad.jefferies@… Owned by: timmywil
Priority: blocker Milestone: 1.6
Component: attributes Version: 1.5
Keywords: Cc:
Blocking: Blocked by:

Description

When scrolled to a point in a page, anywhere below the top and removeAttr("width") or removeAttr("height") is called on an img element, it forces the page to scroll to the top or near the top. Calling the DOM method removeAttribute on the same element does not cause this behavior. The image of course should be the same width and height of the attribute values, so that when the attributes are removed, the image element itself does not adjust.

This happens in the following browsers on a windows xp system: Chrome 8.0.552.237 Firefox 3.6.11 Safari 5.0 (7533.16) IE6 :(

Change History

comment:1 Changed 4 years ago by rwaldron

  • Owner set to chad.jefferies@…
  • Status changed from new to pending
  • Component changed from unfiled to attributes

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!

Additionally, test against the jQuery 0 GIT version to ensure the issue still exists.

comment:2 Changed 4 years ago by jitter

  • Owner changed from chad.jefferies@… to jitter
  • Priority changed from undecided to low
  • Version changed from 1.4.2 to 1.5
  • Status changed from pending to assigned
  • Milestone changed from 1.next to 1.5.1

Confirmed.

 test case

This happens because .removeAttr calls .attr( "height", "" ) before removing the attribute (due some IE bugs). Which in this case basically causes the image height to be 0px for a very short amount of time before the height attribute is removed. Short but long enough for some browsers to reflow the page and jumping to top of the page.

In Chrome, for me, it even breaks scrolling the page after having hit .removeAttr("height").

comment:3 Changed 3 years ago by timmywil

  • Owner changed from jitter to timmywil
  • Priority changed from low to blocker
  • Milestone changed from 1.5.1 to 1.6

Fixed in attrhooks for 1.6.  http://jsfiddle.net/timmywil/YB8VF/7/

comment:4 Changed 3 years ago by timmywil

  • Status changed from assigned to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.