atomic-field-condition
atomic-field-condition
The atomic-field-condition
component takes a list of conditions that, if fulfilled, apply the template in which it’s defined.
The condition properties can be based on any top-level result property of the result
object, not restricted to fields (e.g, isRecommendation
).
Best practices
Usage notes
-
The
must-match
andmust-not-match
markup attributes require kebab-case when referring to a result property whose name is in camelCase. For example, theisRecommendation
property should be written asis-recommendation
.<atomic-field-condition must-match-is-recommendation="true"> <!-- ... --> </atomic-field-condition>
-
Regardless of whether its condition is satisfied, the
atomic-field-condition
component will render all its children and itself. If its condition is not satsified, it will then remove itself and its children from the DOM. For example, consider the following:<atomic-field-condition if-not-defined="thumbnailurl"> <atomic-result-icon class="icon"></atomic-result-icon> </atomic-field-condition> <atomic-field-condition if-defined="thumbnailurl"> <atomic-result-image field="thumbnailurl"></atomic-result-image> </atomic-field-condition>
When the
thumbnailurl
field isn’t defined on a result, theatomic-result-icon
will be rendered as expected. However, theatomic-result-image
(nested in the secondatomic-field-condition
) will also be rendered and subsequently removed from the DOM. This will produce a console warning, as thethumbnailurl
is undefined when it’s referenced by theatomic-result-image
component.
Properties
Property | Attribute | Description | Type | Default |
---|---|---|---|---|
|
A function that must return true on results for the result template to apply.
Set programmatically before initialization, not via attribute.
Use only when the condition you need to define can’t be expressed through |
|
|
|
|
|
Verifies whether the specified fields are defined. |
|
|
|
|
Verifies whether the specified fields are not defined. |
|
|
|
|
The field and values that define which result items the condition must be applied to. For example, a template with the following attribute only applies to result items whose |
|
|
|
|
The field and values that define which result items the condition must not be applied to. For example, a template with the following attribute only applies to result items whose |
|
|