Getters:
"contentName"
This getter will return the name of the icon's content. Which is not the same as the value of its "is" attribute. Let's see an example:
HTML:
Javascript:
As we can see the value of the "is" attribute is maintained, since methods like changeContentFor only change its content.
Methods:
changeContentFor
With this method we can change the content of an icon, without altering its "is" attribute. Lets's see an example:
HTML:
Javascript:
Result:
undoChangeContent
Thanks to this method, we can undo the last change that had an icon through the changeContentFor method. Let's see an example, based on the previous one:
HTML:
Javascript:
Result:
toggleContent
If we want the content of an icon to alternate between one and the other, this is the indicated method.
To give a practical example from real life, let's imagine that we need to make a music player. If this is the case, we would ensure that the playback icon alternates between "play" and "pause", and here the minimum code to make this is possible:
HTML:
Javascript:
Result: