Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#8150 closed bug (fixed)

removeAttr issue in webkit, firefox

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


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 (4)

comment:1 Changed 6 years ago by rwaldron

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

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 6 years ago by jitter

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


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 6 years ago by timmywil

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

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

comment:4 Changed 6 years ago by timmywil

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