Definition of Done
This document provides a checklist for the most common pitfalls, encountered by developers when creating/updating UI5 Web Components.
Properties
- Do I change public properties without user interaction?
Public properties belong to the application. Usually applications bind components' properties to a model. If a component changes its own public properties arbitrarily, the application model may get out of sync. Public properties may only be changed internally upon user interaction (in combination with firing an event).
- Have I set noAttribute for private properties that are not used for CSS?
To keep the components' DOM simple, it's highly recommended to set noAttribute: true for all private
properties that are not needed for CSS rules.
- Does my CSS handle the default values for enum properties?
If a component is styled differently according to the value of an enum property, do not forget to write
your CSS in a way that will apply the default styling even when the property is not set. For example,
if you have a priority enum with values Normal (default) and Important, do not apply the default styles just for
:host[priority="Normal"], but also for simply :host.
Events
- Do I fire an event upon every user interaction?
When the user interacts with a component, an event must always be fired to notify the application of state changes, so that it can update its models.
- Do I allow the application to prevent the default behavior of my events?
Sometimes it makes sense to allow the application to call preventDefault() on en event -
e.g. if there are reasonable conditions that must be met to "allow" the user interaction. In other cases,
this is not necessary and making an event preventable would create unexpected user experience.
Consider what makes the most sense in your particular use case.
- Did I describe my event's details?
If an event that your component fires has event details, you should create a Typescript type, use it in the @event decorator,
use it with fireEvent or fireDecoratorEvent, and finally, export it as a named type export.