Closed Bug 70820 Opened 24 years ago Closed 19 years ago

ALT in broken image cannot be changed by the DOM

Categories

(Core :: Layout: Images, Video, and HTML Frames, defect, P4)

defect

Tracking

()

RESOLVED FIXED
Future

People

(Reporter: ronbu, Assigned: jst)

References

()

Details

(Keywords: testcase, Whiteboard: [Hixie-P2])

Attachments

(3 files)

From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; 0.9) Gecko/20010302 BuildID: 2001030205 When I click the Change button the ALT fails to change to the message I placed in the text field. Here is the function that is supposed to change the ALT. function alt1(){document.IMG1.alt = document.FORM.form.value} Here is the image. <img SRC="im.gif" name="IMG1" WIDTH="300" HEIGHT="100" ALT="YouCanChangeThisText"> Here is the Change button. <input TYPE="button" VALUE="Change" onClick="alt1()"> Reproducible: Always Steps to Reproduce: 1.Point Mozilla to http://www.bekkoame.ne.jp/~hamba/mozilla/HTMLImageElement/alt.html 2. Click the change button. Actual Results: The ALT remains the same. Expected Results: The ALT should change to the text in the text field. This DOM script works fine on IE 5.5 .
First, document.IMG1.alt = foo isn't valid. You need to either use document.getElementByID or document.getElementsByName. That said, after changing the above example it still doesn't work so I'm confirming this with user agent: Mozilla/5.0 (Windows; U; Win98; en-US; 0.9) Gecko/20010302 build: 2001030205 I have a feeling this is another symptom of the problem talked about in bug 22820.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: testcase
QA contact Update
QA Contact: janc → desale
Future for now.
OS: Windows 98 → All
Hardware: PC → All
Target Milestone: --- → Future
Blocks: 61480
Whiteboard: [Hixie-P2]
Updating QA contact to Shivakiran Tummala.
QA Contact: desale → stummala
{ var altVal = document.getElementById("text").value; document.getElementById("image").alt = altVal; alert(document.getElementById("image").alt); } alerts the new value but does not show on the image
Keywords: mozilla1.0
This does not look like a DOM problem. Layout is being provided the attributechanged notification. It just does not do anything with it. Switching to another window and then back will show the new (changed) text. Layout simply needs to repaint when the alt text changes. Attaching patch in a minute.
Simply forces reflow when the alt attribute changes. This makes the correct thing happen with the test case above, and does not do anything funny when the image actually loaded correctly. But I'm still wondering if we should check if the image failed to load before doing this.
Comment on attachment 73851 [details] [diff] [review] one-liner that seems to fix the problem From what I can tell, this does the right thing, and I'm willing to sr it. Someone who understands layout better should have a look at this one-liner and review though. attinasi, dbaron?
Attachment #73851 - Flags: superreview+
Comment on attachment 73851 [details] [diff] [review] one-liner that seems to fix the problem From what I can tell, this does the right thing, and I'm willing to sr it. Someone who understands layout better should have a look at this one-liner and review though. attinasi, dbaron? sr=jst
Errr, I hate it when that happens...
is this a dom problem, comment 6
Priority: -- → P4
attinasi, could you please take a look at the one-liner that seems to fix this bug? thanks in advance :-)
Just a reminder that this one liner is *still* waiting for a review. Does anyone have any suggestions about who in order to get someone to look at this?
Component: DOM Other → Image: Layout
Comment on attachment 73851 [details] [diff] [review] one-liner that seems to fix the problem I am inclined to say that we should check that the image request failed here. It won't cause anything bad to happen because it will just reflow things that don't need it, but that is unnecessary. Harshal, if you want a review, you need to send email to people directly instead of asking in bugs....
Comment on attachment 73851 [details] [diff] [review] one-liner that seems to fix the problem I'm surprised that only a reflow fixes it (and no changes to the frame tree are required). Since testing shows that seems to be the case, r=dbaron. I'm not worried about the performance if the image exists because this seems rare enough that there's no need to optimize.
Attachment #73851 - Flags: review+
well, I stumbled over this rather old patch today... I checked it in, hope that's ok with you all (after I verified that the bug still occurs and that the patch fixes it). I had to apply the patch by hand because it didn't apply. Checking in mozilla/layout/html/base/src/nsImageFrame.cpp; /cvsroot/mozilla/layout/html/base/src/nsImageFrame.cpp,v <-- nsImageFrame.cpp new revision: 1.274; previous revision: 1.273 done
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Sorry, this is not fixed quite yet. It's fixed in quirks mode. It's not fixed in standards mode; as dbaron was guessing, changes to alt text in standards mode require a reframe if the image is not showing.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
One way to fix this would be to use: img:-moz-broken-img::before { content: attr(alt) } once we support the -moz-broken-img pseudo-class...
Fixed in standards mode by bug 11011
Status: REOPENED → RESOLVED
Closed: 22 years ago19 years ago
Depends on: moz-broken
Resolution: --- → FIXED
Product: Core → Core Graveyard
Product: Core Graveyard → Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: