Change record status: 
Project: 
Introduced in branch: 
1.x
Introduced in version: 
1.12.0
Description: 
Before

When an optional property of an object-shaped prop had no value, Canvas substituted the data type's zero value: 0 for integers, '' for strings, FALSE for 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_resolved over 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 || fallback keeps working. One that compared image.width === 0 must compare image.width === undefined instead.
  • A code component that passed image.alt straight to an <img> now renders no alt attribute for an image that never had alt text, where it used to render alt="". Decide explicitly: alt={image.alt ?? ''} keeps the old behavior.
Impacts: 
Module developers
Themers