By wim leers on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
1.x
Introduced in version:
1.12.0
Issue links:
Description:
- Before
-
When an optional property of an object-shaped prop had no value, Canvas substituted the data type's zero value:
0for integers,''for strings,FALSEfor booleans. For example, an SVG image, whose dimensions the image toolkit cannot read, resolved to:{"src": "/sites/default/files/logo.svg", "alt": "Logo", "width": 0, "height": 0} - After
-
-
Optional unpopulated properties are omitted:
{"src": "/sites/default/files/logo.svg", "alt": "Logo"}This is visible in
inputs_resolvedover the internal HTTP API and in the props a code component receives. SDCs use Twig templates and hence are unaffected: an absent variable prints as an empty string. -
Required SDC/code component props are unaffected: Canvas only maps a required prop onto a field property that is itself required, and an empty required property is still treated as inaccessible.
-
What to do
- A code component that read
image.width || fallbackkeeps working. One that comparedimage.width === 0must compareimage.width === undefinedinstead. - A code component that passed
image.altstraight to an<img>now renders noaltattribute for an image that never had alt text, where it used to renderalt="". Decide explicitly:alt={image.alt ?? ''}keeps the old behavior.
Impacts:
Module developers
Themers