Skip to content

Instantly share code, notes, and snippets.

@indzi
Last active February 6, 2018 07:55
Show Gist options
  • Select an option

  • Save indzi/2d308c14e339b39b599053b3ffd7ee69 to your computer and use it in GitHub Desktop.

Select an option

Save indzi/2d308c14e339b39b599053b3ffd7ee69 to your computer and use it in GitHub Desktop.
Don’t forget: Polymer camel-cases properties, so if in JavaScript you use myProperty, in HTML you would use my-property.
<some-element hidden$="[[myProperty]]"></some-element>
Attribute binding: when myProperty is true, the element is hidden; when it’s false, the element is visible. The difference between attribute and property binding is that property binding is equivalent to someElement.someProp = value, whereas attribute binding is equivalent to: someElement.setAttribute(someProp, value)
Computed binding: binding to the class attribute will recompile styles when myProperty changes:
<some-element class$="[[_computeSomething(myProperty)]]"></some-element>
<script>
_computeSomething: function(prop) {
return prop ? 'a-class-name' : 'another-class-name';
}
</script>
<some-element their-property="[[myProperty]]"></some-element>
<some-element their-property="{{myProperty}}"></some-element>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment