Closed Bug 1058333 Opened 10 years ago Closed 4 years ago

Navigation: Difficult to find event handler info from HTML element page

Categories

(Developer Documentation Graveyard :: API: HTML, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: jswisher, Unassigned)

References

()

Details

A user pointed this out in IRC. It's not easy to find info on event handlers (e.g., onload or onerror) when you are on a reference page for an HTML element (e.g, img). You have to click up through the DOM interface inheritance tree (img > HTMLImageElement > HTMLElement > GlobalEventHandlers > event handler), to find the one you care about. This is 4 clicks, in this example case, and assumes that the user understands enough about DOM programming to realize that GlobalEventHandlers is the place to look, and doesn't waste time looking at Element. (In contrast, in W3Schools, this takes 2 clicks: img > Global Event Attributes > event handler.)
Yep, known problem. The GEH attributes should appear on HTMLElement (as they are implemented and not inherited). This will be fixed the day we get rid of the old look. There was a beginner task created for this. Also we need a way to add the inherited attributes/methods on HTMLImageElement (maybe in the quicklinks). Finally, <img> should list events (not event handler) fired on it, and when, but this is huge task.
So one point that I missed in comment1 is that the global attributes includes a lot of onXYZ attributes [1] Unfortunately most of these onXYZ does nothing but on (variable) 3-4 elements, so only listing all of them would be useless. I think we should list the relevant onXYZ for each element both in the sidebar and in the global attributes messages. This would solve the problem in <img>. To do this, I think we should have the relevant onXYZ listed in a .json HTMLData macro. This won't be a trivial task, I guess. ni/ Florian and Sebastian for feedback here. [1] See https://html.spec.whatwg.org/#global-attributes
Flags: needinfo?(sebastianzartner)
Flags: needinfo?(fscholz)
I was mistaken, we don't list the attributes in the sidebar for HTML, so this would only appears in the global attributes sections at the beginning of the attribute section of each HTML element.
(In reply to Janet Swisher from comment #0) > You have to click up through the DOM interface inheritance tree (img > > HTMLImageElement > HTMLElement > GlobalEventHandlers > event handler), to > find the one you care about. This is 4 clicks I don't remember how it was when this bug was filed, though the above is not correct anymore. Global event attributes can be reached by one click ('global attributes') and global event handlers only require two clicks (HTMLImageElement > <event handler in sidebar>). So, what could be improved is showing only event attributes relevant for the current element. And besides that, the global attributes page should describe each event attribute and not just list them in this unclear way. (In reply to Jean-Yves Perrier [:teoli] from comment #3) > I was mistaken, we don't list the attributes in the sidebar for HTML, so > this would only appears in the global attributes sections at the beginning > of the attribute section of each HTML element. I'd list all global attributes within the sidebar, as they are related to all HTML elements. Or at least a link to the global attributes page. Though that's probably also another topic. (In reply to Jean-Yves Perrier [:teoli] from comment #2) > I think we should list the relevant onXYZ for each element both in the > sidebar and in the global attributes messages. This would solve the problem > in <img>. I agree with that. Instead of writing all in a sentence, I'd create an unordered list. As the list can still get quite long (onclick, onmousemove, ondrag, etc. work for all elements), we may consider allowing to collapse it. > To do this, I think we should have the relevant onXYZ listed in a .json > HTMLData macro. This won't be a trivial task, I guess. Creating an HTMLData template is already filed in bug 1220135. Depending on how we decide, this bug should be marked as blocked by bug 1220135. Here's an example for how the info about event attributes could be stored: { "elements": { "img": { ... "eventAttributes": ["onload", "onloadstart", "onloadend", "onclick", ... ] } ... }, ... "eventAttributes": [ "onabort", "onautocomplete", "onautocompleteerror", ... ] } Sebastian
Flags: needinfo?(sebastianzartner)
Depends on: 1220135
Flags: needinfo?(fscholz)
Assignee: jypenator → nobody
MDN Web Docs' bug reporting has now moved to GitHub. From now on, please file content bugs at https://github.com/mdn/sprints/issues/ and platform bugs at https://github.com/mdn/kuma/issues/.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.