[whatwg] Need clarification on menu builder algorithm for contextmenu attribute

2014-08-26 Thread Sanjoy Pal
Hi,

I am trying to implement the menu builder algorithm from this part of
specification

http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#menu-
builder

 

I feel the following statement for the third bullet of step 2,

if the child is a
http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#the-
menu-element menu element with no
http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#attr
-menu-label label attribute, Append a separator to the menu, then run the
http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#menu
-builder menu builder steps using this child
http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#the-
menu-element menu element for the same menu, then append another separator
to the menu.

is contradicting the statement of step 3

Remove any submenu with no label, or whose label is the empty string, in
the menu or any submenus.

 

My understanding  from the first statement is that the any child menu
(submenu) with no label attribute should be flattened. But the subsequent
statement implies removal of whole submenu.

 

Can someone please explain the difference between the above two statements?

 

Thanks and regards,

Sanjoy Pal



 



Re: [whatwg] Need clarification on menu builder algorithm for contextmenu attribute

2014-08-26 Thread Ian Hickson
On Tue, 26 Aug 2014, Sanjoy Pal wrote:
 
 I feel the following statement for the third bullet of step 2,
 
 if the child is a menu element with no label attribute, Append a 
 separator to the menu, then run the menu builder steps using this child 
 menu element for the same menu, then append another separator to the 
 menu.
 
 is contradicting the statement of step 3
 
 Remove any submenu with no label, or whose label is the empty string, 
 in the menu or any submenus.
 
 My understanding from the first statement is that the any child menu 
 (submenu) with no label attribute should be flattened. But the 
 subsequent statement implies removal of whole submenu.

It's important not to confuse a child menu element with an actual 
submenu in the constructed menu. (This is similar to the difference 
between a section and a section.)

There are two concepts here. Elements, including menu and menuitem, 
are your regular DOM element node. Pop-up menus, on the other hand, are 
lists of zero or more menu items, and menu items are commands, separators, 
and recursively other pop-up menus.

When you have a child menu element with no label attribute, no submenu 
is created. The child menu items are inserted directly into the parent 
menu. So when it comes to the second statement quoted above, there's no 
submenu to remove. The second statement above could get triggered for 
something like menu label= (an empty label).

I've tweaked the wording a bit to try to make this clearer. In particular 
I've made the terminology less ambiguous.

HTH,
-- 
Ian Hickson   U+1047E)\._.,--,'``.fL
http://ln.hixie.ch/   U+263A/,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'