Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are difference between hostAttributes and properties in polymer?

I'm doing migration from 0.5 to 1.0.

While reading, I notice 2 different way on declaring attributes, using hostAttributes and properties.

What are difference between those 2 ?

like image 774
Yana Agun Siswanto Avatar asked Jun 09 '15 05:06

Yana Agun Siswanto


People also ask

How do the properties of polymers depend on their structures?

The properties of synthetic polymers depend on their structures. For example, HDPE consists of straight chains packed together densely and is hard and strong. On the other hand, LDPE consists of branched chains, and is much softer and more flexible. How does the structure of a polymer affect its properties?

Which of the following is an example of polymer?

Examples of polymers are rubber, plastics, and nylon. The properties of a polymer are affected by the structure, type of monomer units from which polymers are formed, and other factors. Polymers have different physical and chemical properties, which are listed below:

What is the difference between attributes and properties in HTML?

Some DOM properties don’t possess corresponding attributes. Some HTML attributes don’t possess corresponding properties. Some HTML attributes, like ‘class’, possess 1:1 mapping to properties. Let us take a look at some quick examples to demonstrate the differences between attributes and properties. Example: Consider the following HTML code snippet.

What is the difference between property and non-custom attributes?

associated with it. Default attributes (non-user-defined) change when corresponding property changes and vice-versa. Non-custom attributes (like id, class, etc.) have 1:1 mapping to the properties. We use ‘className’ to access (get or set) the ‘class’ property because ‘class’ is a reserved keyword in JavaScript.


1 Answers

Host attributes are attributes that do not match to an element's corresponding Javascript property (which you declare in properties). This includes attributes like class, tabindex, data-* attributes, aria-roles, etc. To declare them during create-time, you must set them in the hostAttributes object. If you are going to bind values into them, you must use $= (which calls Element.setAttribute) rather than =.

Sources:

  • https://www.polymer-project.org/1.0/docs/devguide/registering-elements.html#host-attributes
  • https://www.polymer-project.org/1.0/docs/devguide/data-binding.html#attribute-binding
like image 160
Neil John Ramal Avatar answered Oct 20 '22 22:10

Neil John Ramal