In the preceding article, I demonstrated adding a SVG graphic to a <xul:menuitem/>. This is one case where I saw a quick & easy way to bend the rules of XUL. Menu items typically don’t have children, so giving it a <svg:svg/> child somewhat made sense.
XUL Widgets uses a similar trick for <xul:textbox/>. In this one, the textbox gets menuitems, menuseparators, and menus which should be added to the standard textbox’s context menus, before the first item in the context menu. Admittedly, this is not as clear-cut as the SVG example, but it does have one benefit: it doesn’t break existing textbox functionality. (I blogged about this previously.)
I made a mistake several years ago in filing bug 180512. That was my earlier attempt to add items to a textbox’s context menu – by replacing the context menu. The problem is that change broke Undo, Redo, Cut, Copy, Paste, Delete in any non-default context menu. It should never have been done. (I since filed bug 312869 to fix this botch.)
These are to date the only reasons I’ve had to define new behaviors for children of XUL widgets. The two are different enough that the behaviors for these specific cases can be clearly defined and have a clear benefit.
If you have other ideas, I’ll definitely consider them.