3

According to documentation one can override tokens. From my point of view it is very bad to do this.

1 Because once you override a token in a child token bundle, the value which is specified in parent token bundle becomes rotten and anyone who will read the parent token bundle will be deceived.

2 Also, it is not clear even from documentation what will happen once you override a specific parent token in two different children with two different values.

So, given those two above drawbacks I would resort to always changing token values in parent token bundle instead of overriding them.

That is why I am asking what is the use of being able to override tokens in lightning if any?

Thank you.

1 Answer 1

2

To determine which bundle you're using, you check the app:

<aura:application tokens="c:bundle2">
    <!-- we now have bundle1 and bundle2 styles! -->
    <!-- Your app markup here -->
</aura:application>

1 Because once you override a token in a child token bundle, the value which is specified in parent token bundle becomes rotten and anyone who will read the parent token bundle will be deceived.

In a general sense, that's not true. When you read bundle2 first, you'll understand that bundle1 has overridden tokens in it. You need to read them "together" to get the full picture. This is the exact same concept as base classes and extended classes; extended classes can override base class methods ("virtual methods"). The overrides for bundle2 only apply when you use bundle2. Bundle1 remains unaffected by any children.

2 Also, it is not clear even from documentation what will happen once you override a specific parent token in two different children with two different values.

Nothing spectacular happens. Given parent bundle1, and child bundles bundle2 and bundle3, if you use bundle1, you only get those tokens, and if you use bundle2, then you get bundle1 and bundle2 (including overrides), and if you use bundle3, you get bundle1 and bundle3 (including overrides).


<aura:application tokens="c:bundle2">
    <!-- we now have bundle1 and bundle2 styles! -->
    <!-- Your app markup here -->
</aura:application>

<aura:application tokens="c:bundle1">
    <!-- we now have bundle1 styles! -->
    <!-- Your app markup here -->
</aura:application>

<aura:application tokens="c:bundle3">
    <!-- we now have bundle1 and bundle3 styles! -->
    <!-- Your app markup here -->
</aura:application>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .