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:

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

comment:1 Changed 6 years ago by Rick Waldron

Component: unfiledattributes
Owner: set to chad.jefferies@…
Status: newpending

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: 1.next1.5.1
Owner: changed from chad.jefferies@… to jitter
Priority: undecidedlow
Status: pendingassigned
Version: 1.4.21.5

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

Milestone: 1.5.11.6
Owner: changed from jitter to timmywil
Priority: lowblocker

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

comment:4 Changed 6 years ago by timmywil

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.