Closed Bug 151245 Opened 22 years ago Closed 22 years ago

img src not able to be set in onerror/onclick handler

Categories

(Core :: DOM: Events, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 22820

People

(Reporter: bc, Assigned: bryner)

Details

(Keywords: topembed+)

Attachments

(5 files, 1 obsolete file)

I looked but could not find this bug in bugzilla. The following two test cases work in IE6 and Nav4 but do not work in Mozilla trunk or branch 2002 06 10 This bug is important for a major web site. I need to know what the situation is with this bug ASAP.
Attached file testcase img onerror
Attached file testcase a onclick
Keywords: nsbeta1, topembed
Note that onmouseover can change the src of an img
Attached file fixed workaround
Attachment #87506 - Attachment is obsolete: true
joki is gone -> bryner
Assignee: joki → bryner
So, the main problem here is that kicking off a new image load happens via nsImageFrame's handling of the 'src' attribute change. In the case where the image originally failed to load, we've constructed an nsInlineFrame instead of an nsImageFrame, so there is no handling of the src attribute change. I think we need to make a reframe happen in this case.
It's kind of gross, but I came up with a workaround that tells the document that the image content has been replaced if 'src' is set and we have a frame that's not an image frame. Per conversation with dbaron, a better way to fix this would be to move the image loading code into nsHTMLImageElement and then notify the frame constructor that it needs to construct a new frame, either via a direct API or by having a CSS pseudoclass that indicates that the element is replaced (we would unset the pseudoclass when the 'src' is chanegd, and the style system would know to construct a new frame).
Status: NEW → ASSIGNED
Attached patch hacky fixSplinter Review
Actually, there's a better discussion of the problem and a possible fix over in bug 22820. The failure of the testcases here does not have anything to do with being in an onerror or onclick handler, it's all because the original image src was invalid. *** This bug has been marked as a duplicate of 22820 ***
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: