This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 22517 - replace the <menu> element with new <toolbar> and <popup> elements
Summary: replace the <menu> element with new <toolbar> and <popup> elements
Status: RESOLVED WORKSFORME
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard: blocked on having better suggested na...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-29 09:37 UTC by Michael[tm] Smith
Modified: 2015-08-28 04:28 UTC (History)
2 users (show)

See Also:


Attachments

Description Michael[tm] Smith 2013-06-29 09:37:21 UTC
From the point of view of a Web authors, the current <menu> element is effectively two different elements: a toolbar or a popup. Using an attribute value to subtype an element for multiple, distinctly different purposes is an ugly antipattern that leads to confusion for Web authors, and unnecessary complications for writers of documentation on how to use HTML.
Comment 1 Michael[tm] Smith 2013-06-29 10:38:39 UTC
In particular the following part of the spec really exposes why having a single element for both popups and toolbars is ugly:

"The missing value default is the popup menu state if the parent element is a menu element whose type attribute is in the popup menu state; otherwise, it is the toolbar state."

Nobody should need to check the parent of an element to figure out what the element is -- what it's for, what the purpose of the element is -- the element's semantics should be unambiguous just from examining the element itself.

If we had separate elements for popups and toolbars, none of the spec language around "missing value default" here would be needed, and all of unnecessary complications for Web authors and documentation writers and implementors would be eliminated.
Comment 2 Ian 'Hixie' Hickson 2013-07-03 19:48:53 UTC
Well, the toolbar version is literally just the old <menu> from the 90s.

<menu type=popup> is only required on the outermost menu, to make it invisible. That's the only reason for the prose you quote that you say is complicated. In practice I don't think it's not confusing at all. Tutorials don't need to mention this, they just need to say "and when you have a submenu, you don't need a type attribute, it's implied".

I agree that with the way the feature is currently specced the old benefits to reuse <menu> for menus are mostly gone. The main advantage now is just the element's name being so perfect, but that's kinda lost with the attribute on the outer one, granted.

We could rename <menu type=popup> to something else... I can't really think of anything that would be any more pithy, though.
Comment 3 Michael[tm] Smith 2013-07-04 11:03:37 UTC
(In reply to comment #2)
> Well, the toolbar version is literally just the old <menu> from the 90s.
> 
> <menu type=popup> is only required on the outermost menu, to make it
> invisible. That's the only reason for the prose you quote that you say is
> complicated. In practice I don't think it's not confusing at all. Tutorials
> don't need to mention this, they just need to say "and when you have a
> submenu, you don't need a type attribute, it's implied".
> 
> I agree that with the way the feature is currently specced the old benefits
> to reuse <menu> for menus are mostly gone. The main advantage now is just
> the element's name being so perfect, but that's kinda lost with the
> attribute on the outer one, granted.
> 
> We could rename <menu type=popup> to something else... I can't really think
> of anything that would be any more pithy, though.

Mint a new <submenu> element instead.
Comment 4 Ian 'Hixie' Hickson 2013-07-09 21:47:37 UTC
<submenu> wouldn't work for the contextmenu="" use case and the <button menu=""> use case. (It would work for the <menu type=popup><menu> use case, but that's the least problematic one, IMHO.)
Comment 5 Michael[tm] Smith 2013-07-10 02:00:02 UTC
(In reply to comment #2)
> Well, the toolbar version is literally just the old <menu> from the 90s.

Which is really nothing more than an alias for <ul>. But yeah I can see that for backwards-compatibility reasons, we can't change that.

> We could rename <menu type=popup> to something else... I can't really think
> of anything that would be any more pithy, though.

What about just <popupmenu> or <contextmenu>?

<contextmenu> would be better since we already have "contextmenu" for the global attribute. And menu@type=popup was originally type=context anyway -- and actually is implemented as type=context in the only UA that implements any of this.

And yeah I know what the rationale[1] for having type=popop instead of type=context is, but that doesn't seem to me like such a strong rationale. I think we could have a <button type=menu menu=""> point to a <contextmenu> element without doing damage to semantic purity.

But then I think <popupmenu> would be OK too.

[1] http://lists.w3.org/Archives/Public/public-whatwg-archive/2012Dec/0264.html
[[
<menu type=popup> is implemented as <menu type=context> in Gecko. This is an unfortunate incompatibility. I renamed "context" to "popup" because it doesn't make sense to have <button type=menu menu=""> pointing at a <menu type=context> since then it's not a context menu but a drop-down menu. Since both context menus and drop-down menus are also called "pop-up menus" I went with "popup". If there's too much content depending on type=context let me know and I'll change it back.
]]
Comment 6 Michael[tm] Smith 2013-07-10 02:05:04 UTC
(In reply to comment #5)
> And yeah I know what the rationale[1] for having type=popop instead of
> type=context is, but that doesn't seem to me like such a strong rationale. I
> think we could have a <button type=menu menu=""> point to a <contextmenu>
> element without doing damage to semantic purity.

Data point: if you try to look up "Popup menu" in Wikipedia, it redirects to "Context menu":

  http://en.wikipedia.org/wiki/Popup_menu

"A context menu (also called contextual, shortcut, and popup or pop-up menu) is a menu in a graphical user interface (GUI) that appears upon user interaction..."
Comment 7 Ian 'Hixie' Hickson 2013-07-13 15:36:06 UTC
I think I'd be happier with finding a way to just dump the attribute than minting a new element with a long name like that.
Comment 8 Michael[tm] Smith 2013-07-14 07:57:57 UTC
(In reply to comment #7)
> I think I'd be happier with finding a way to just dump the attribute than
> minting a new element with a long name like that.

We could drop menu@type=toolbar completely and define <menu> as being what menu@type=popup is defined as now.

A document marked up with <menu><li>.. would be a document-conformance error. For the validator, I could have it emit a message saying "Using the ul element instead."
Comment 9 Ian 'Hixie' Hickson 2013-07-15 23:28:17 UTC
That could work. Do you have any visibility into how common <menu> is?
Comment 10 Ian 'Hixie' Hickson 2013-07-15 23:29:40 UTC
I meant in the validator, but actually, that's a non-starter, since we need to hide <menu> from the rendering and can't hide the legacy <menu>s (it's common in legacy pages).
Comment 11 Ian 'Hixie' Hickson 2013-09-12 20:29:24 UTC
I can't think of anything better than <menu type=popup> for the outermost self-hiding element of a context menu or drop-down menu definition.
Comment 12 Michael[tm] Smith 2013-09-14 08:24:32 UTC
(In reply to Ian 'Hixie' Hickson from comment #11)
> I can't think of anything better than <menu type=popup> for the outermost
> self-hiding element of a context menu or drop-down menu definition.

In the mean time, I've not thought of any new suggestions either.
Comment 13 Ian 'Hixie' Hickson 2013-09-16 17:55:23 UTC
I'll leave this open until implementations make this moot, in case we come up with a better name before then.
Comment 14 Michael[tm] Smith 2015-08-28 04:28:10 UTC
I don't feel strongly about this to keep it open. I (or somebody) can re-raise it at github if we want to re-pursue it in the future.