Closed Bug 120607 Opened 23 years ago Closed 23 years ago

nsGenericHTMLElement::HasAttribute() sometimes returns false when attribute exists

Categories

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

defect
Not set
critical

Tracking

()

VERIFIED FIXED
mozilla0.9.8

People

(Reporter: cmanske, Assigned: cmanske)

Details

(Keywords: regression)

Attachments

(2 files, 1 obsolete file)

Using "element.hasAttribute()" on an element in a document being edited is
always returning false when I know it exists. In JS code, foo.getAttribute()
returns a 
value and foo.attributes.getNamedItem() correctly returns an attribute node.
I'll attach a test file.
This problem would seem rather critical!
Severity: normal → critical
I did some debugging and find that some attributes do succeed: E.g., if I have
an "img" with "width", "height", and "alt" set, the "width" and "height" are 
found by FindHTMLAttribute(), but "src" and "alt" are not.
The search for attributes starts with "mFirst". Could this be wrong?
cc'ing Hewitt, since he wrote nsHTMLMappedAttributes::GetAttribute().
Summary: nsGenericHTMLElement::HasAttribute() always returns false → nsGenericHTMLElement::HasAttribute() sometimes returns false when attribute exists
Note that the test file seems to succeed in NS 6.2.1 because "HasAttribute()"
wasn't implemented! So that fact is irrelevant.
Since Hewitt implemented this stuff recently (12/10/01), reassigning to him.
Assignee: jst → hewitt
Attached patch Proposed patch (obsolete) — Splinter Review
Not all attributes are mapped attributes.  Mapped ones worked fine with the
existing code, non-mapped ones broke.
reviews?
Keywords: patch, review
OS: Windows 2000 → All
Hardware: PC → All
I just figured out the same thing!
Comment on attachment 65466 [details] [diff] [review]
Another version, somewhat simpler

darn, attached wrong diff! line should be:
+  if (mMapped && mMapped->HasAttribute(aAttrName))

of course! (no ";")
That works too.  :)

jst, is there a function that takes and nsIAtom and quickly says "mapped" or
"not mapped" so that we can avoid doing FindHTMLAttribute for mapped attributes
that are note set?
Comment on attachment 65466 [details] [diff] [review]
Another version, somewhat simpler

Whether or not an attribute is mapped or not depends on the element, so there
is no such method AFAIK.

sr=jst
Attachment #65466 - Flags: superreview+
Comment on attachment 65466 [details] [diff] [review]
Another version, somewhat simpler

Ok, then.  r=bzbarsky
Attachment #65466 - Flags: review+
Attachment #65463 - Attachment is obsolete: true
Thanks for reviews. Should we check this in for 0.9.8? (I'll ask drivers for that)
Assignee: hewitt → cmanske
Target Milestone: --- → mozilla0.9.8
this testcases passed in 6.2.1 RTM, it is a regression from Gecko/20011128
Keywords: regression
a=blizzard on behalf of drivers for 0.9.8
Keywords: mozilla0.9.8+
I saw a checkin comment referencing this bug: "01/18/2002
12:08cmanske%netscape.com mozilla/ content/ html/ style/ src/
nsHTMLAttributes.cpp 3.66 2/2  Fixed hasAttribute for non-mapped attributes,
b=120607, r=bzbarsky@mit.edu, sr=jst, a=blizzard/drivers"

Is it resolved? If so, can you mark it Fixed to pull it from the "0.9.8
outstanding" list? Thanks.
checked in.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
verified fixed. build 2002-01-25-08
Status: RESOLVED → VERIFIED
Component: DOM: Core → 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: