Closed Bug 95476 Opened 23 years ago Closed 22 years ago

HTMLObjectElement.tabIndex returning -1

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla1.0

People

(Reporter: stummala, Assigned: jst)

Details

(Keywords: testcase, Whiteboard: [HAVE FIX])

Attachments

(1 file)

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.2)
Gecko/20010726 Netscape6/6.1
BuildID:    2001-08-13-09-trunk

HTMLObjectElement.tabIndex returning -1 .attached a testcase to demonstrate the
problem..


Reproducible: Always
Steps to Reproduce:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body>
<object DATA="http://bubblegum/ngdriver/suites/res/mondrian8.jpg" usemap="#map1"
tabIndex="2">
This is a <em>picture</em> of the word Marvin with a border of 4.
</object>
<map name="map1">
<area shape="rect" alt="red" coords="0,0, 63,61"
href="http://bubblegum/ngdriver/suites/res/red.html">
</map>

<script TYPE="text/javascript">

var obj = document.getElementsByTagName("OBJECT").item(0);
document.write("<BR>" + obj.useMap + "<BR>");
document.write(obj.tabIndex);

</script>
</body>
</html>



Actual Results:  -1

Expected Results:  2
Target Milestone: --- → mozilla0.9.8
Futuring.
Target Milestone: mozilla0.9.8 → Future
Pretty sure it's again a unit problem, however this time I can't explain it...
the html4.0 spec says tabindex is a number, so NS_IMPL_INT_ATTR should do the
right thing. Findings for the record:

<object id="obj" tabindex="2">Picture</object>

var obj = document.getElementById("obj");
alert(obj.getAttribute("tabindex")); // Alerts "2"
alert(obj.tabIndex); // Alerts "-1"

obj.setAttribute("tabindex", 5);
alert(obj.tabIndex); // Alerts "-1"

obj.tabIndex = 10;
alert(obj.tabIndex); // Alerts "10"
This is probably due to the lack of handling of tabindex in
nsHTMLObjectElement::StringToAttribute(), see
nsHTMLAnchorElement::StringToAttribute() for an example of how to make this work.
Attached patch Proposed fix.Splinter Review
As usual, you were right :-)
Jonas, I need your services again ;-)
Whiteboard: [HAVE FIX]
Target Milestone: Future → mozilla1.0
Actually I have a question... StringToAttribute() is called by SetAttr(),
however here it's GetAttr() that's not working, isn't it? nsHTMLAnchorElement
doesn't have a AttributeToString() method. Strange.
Comment on attachment 67724 [details] [diff] [review]
Proposed fix.

r=sicking assuming you've tested this and it works.
Attachment #67724 - Flags: review+
If the attribute doesn't get parsed as an eHTMLUnit_Integer then GetTabIndex 
will fail, see 

http://lxr.mozilla.org/mozilla/source/content/html/content/src/nsGenericHTMLElem
ent.h#738
Comment on attachment 67724 [details] [diff] [review]
Proposed fix.

There's default code that deals with converting integer attribute values into
strings when GetAttr() is called, no need to duplicate that all over. Here
GetAttr() is working, but we get back the wrong type of attribute, so .tabIndex
can't convert the value into a integer.

sr=jst, thanks for the fix!
Attachment #67724 - Flags: superreview+
as we have fix on hand, i am nominating for nsbeta1
Keywords: nsbeta1
Keywords: testcase
I don't see this being worth nsbeta1+, but since there is a fix we should check
it in. No need to wait for 1.0 even, go for it, anyone!
Keywords: nsbeta1nsbeta1-
Fixed.
Status: NEW → RESOLVED
Closed: 22 years ago
Hardware: PC → All
Resolution: --- → FIXED
marking verified
Status: RESOLVED → VERIFIED
Component: DOM: HTML → DOM: Core & HTML
QA Contact: stummala → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: