-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Challenges of building a menu system in Polymer #382
Comments
I'm afraid it's hard to comment because it seems your commentary is either too general (at least, for me) or represents opinions about how things work. It's definitely true that if you dislike Polymer idioms in general, you will have a hard time using Polymer. For sure, where there are real specific things that Polymer just does not support in a reasonable way, we definitely want to understand those flaws, but this is different from simply wanting it to work differently. Polymer already has an example menu system (polymer-ui-menu, polymer-ui-menu-item, and polymer-ui-submenu-item). I suspect you feel it doesn't meet your needs, which is reasonable, but at least it demonstrates that Polymer isn't somehow incapable of expressing such a system. |
Wrt to this specific question, ShadowDOM is particularly good at plucking out only nodes that match certain selectors. Given,
Non-menu-item elements are simply ignored. |
I recommend investigating if polymer-selector would be useful. It exists to To elaborate on what Scott said: Menu can have a shadowDOM like this: In that case the menu items are still the children of the menu as you've On Wed, Dec 18, 2013 at 2:14 PM, Scott J. Miles notifications@github.comwrote:
|
Selector is great. It confirms my intuitions, though, that it's actually hard to get these components really right. You have to take care of many cases, and I just started to think about this as well. I'm surprised with the use of MutationObserver. It has no specificity, correct? It's calling updateSelected on all DOM mutations in the entire document? These things are not good at plucking, from my perspective, as I want to pluck based on superclass. Like, I have an "abstract-menuitem", which is sub-classed by "menupane-item" and "menubar-item". I'd like to select on that, and it's not easy. If I could pass in a selector that was a predicate function, that would be good. I would write a function that performs this type check. Else, I'd have to rely on CSS or some attribute... so I'd expose some internal details. |
Just mutations generated within the target element. I want to pluck based on superclass Yeah, that's not supported right now and instead you'll need either to list On Thu, Dec 19, 2013 at 3:11 PM, jganetsk notifications@github.com wrote:
|
So I'm building a menu system in Polymer.
I'm expressing the menu contents in HTML, using just custom elements, with something that looks like
I have certain simple constraints, like
I have other more particular constraints regarding more subtle points about how people expect menus to work.
I have mainly implemented this with changed watchers, and it's fairly straightforward to understand how to respond to any given change, with bidirectionality (you can change either the parent, or the child, and the other responds correctly). But there are some gotchas:
The text was updated successfully, but these errors were encountered: