Apply attribute-based behavior to a host element by default?

31 views
Skip to first unread message

Michael Bleigh

unread,
Sep 12, 2014, 2:34:01 PM9/12/14
to polym...@googlegroups.com
Is there any way to reliably attach attribute-based behavior to custom elements by default? There are two cases I'm thinking of:
  1. Wanting to have a host element automatically apply layout attributes to itself
  2. Wanting to add touch-action on a host element by default
In the former case, I know that I can do the CSS manually (but it'd be nice not to have to) but I'm not sure how to accomplish the latter case short of actually adding the attribute during the created callback, but that pollutes the DOM a bit. I'm working around it for now by having an inner container, but I'd prefer not to have to do that.

Any "right way" to do this?

Eric Bidelman

unread,
Sep 12, 2014, 2:45:35 PM9/12/14
to Michael Bleigh, polymer-dev
Hi Michael,

You can add default attributes by including them on the <polymer-element> definition. Any custom attrs will be included on an instance of the element:


Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/e748660c-32fb-4bd1-99af-c27c886176e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Bleigh

unread,
Sep 12, 2014, 3:08:15 PM9/12/14
to polym...@googlegroups.com, mbl...@gmail.com
Great, thanks! Not 100% a fan of having the attributes end up in the DOM (I'd prefer to be able to enable the functionality invisibly), but certainly a workable solution.
Reply all
Reply to author
Forward
0 new messages