diff -u b/core/modules/file/src/Element/ManagedFile.php b/core/modules/file/src/Element/ManagedFile.php --- b/core/modules/file/src/Element/ManagedFile.php +++ b/core/modules/file/src/Element/ManagedFile.php @@ -353,16 +353,13 @@ // with it. $element['#id'] = &$element['upload']['#id']; - // Add states to ajax wrapper to states.js can potentially attach this + // Add states to ajax wrapper so states.js can potentially attach this // element as a Dependent. $attributes = ''; if (isset($element['#states']) && !empty($element['#states'])) { - $attribute = new Attribute([ + $attributes = new Attribute([ 'data-drupal-states' => json_encode($element['#states']), ]); - - // Add a preceeding space. - $attributes = ' ' . $attribute; } // Prefix and suffix used for Ajax replacement.