diff --git a/core/includes/form.inc b/core/includes/form.inc
index 8170820..144e3a2 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -43,7 +43,7 @@ function template_preprocess_select(&$variables) {
}
/**
- * Converts an array of options into HTML, for use in select list form elements.
+ * Converts an options form element into a structured array for output.
*
* This function calls itself recursively to obtain the values for each optgroup
* within the list of options and when the function encounters an object with
@@ -78,13 +78,16 @@ function template_preprocess_select(&$variables) {
* $element['#options'] above, or NULL. This parameter is only used internally
* and is not intended to be passed in to the initial function call.
*
- * @return string
- * An HTML string of options and optgroups for use in a select form element.
+ * @return array
+ * A structured array of options and optgroups for use in a select form
+ * element.
+ *
+ * @todo Document the format of this array.
*/
function form_select_options($element, $choices = NULL) {
if (!isset($choices)) {
if (empty($element['#options'])) {
- return '';
+ return [];
}
$choices = $element['#options'];
}
@@ -94,29 +97,36 @@ function form_select_options($element, $choices = NULL) {
$value_is_array = $value_valid && is_array($element['#value']);
// Check if the element is multiple select and no value has been selected.
$empty_value = (empty($element['#value']) && !empty($element['#multiple']));
- $options = '';
+ $options = [];
foreach ($choices as $key => $choice) {
if (is_array($choice)) {
- $options .= '';
+ $options[] = [
+ 'type' => 'optgroup',
+ 'label' => $key,
+ 'options' => form_select_options($element, $choice),
+ ];
}
elseif (is_object($choice) && isset($choice->option)) {
- $options .= form_select_options($element, $choice->option);
+ $option = form_select_options($element, $choice->option);
+ $options[] = reset($option);
}
else {
+ $option = [];
$key = (string) $key;
$empty_choice = $empty_value && $key == '_none';
if ($value_valid && ((!$value_is_array && (string) $element['#value'] === $key || ($value_is_array && in_array($key, $element['#value']))) || $empty_choice)) {
- $selected = ' selected="selected"';
+ $option['selected'] = TRUE;
}
else {
- $selected = '';
+ $option['selected'] = FALSE;
}
- $options .= '';
+ $option['type'] = 'option';
+ $option['value'] = $key;
+ $option['label'] = $choice;
+ $options[] = $option;
}
}
- return SafeMarkup::set($options);
+ return $options;
}
/**
diff --git a/core/modules/ckeditor/js/ckeditor.js b/core/modules/ckeditor/js/ckeditor.js
index 4254f00..4cc77aa 100644
--- a/core/modules/ckeditor/js/ckeditor.js
+++ b/core/modules/ckeditor/js/ckeditor.js
@@ -30,7 +30,7 @@
// Set a title on the CKEditor instance that includes the text field's
// label so that screen readers say something that is understandable
// for end users.
- var label = $('label[for=' + element.getAttribute('id') + ']').html();
+ var label = $('label[for=' + element.getAttribute('id') + ']').text();
format.editorSettings.title = Drupal.t("Rich Text Editor, !label field", {'!label': label});
// CKEditor initializes itself in a read-only state if the 'disabled'
diff --git a/core/modules/system/templates/select.html.twig b/core/modules/system/templates/select.html.twig
index 21f32ac..fb7226e 100644
--- a/core/modules/system/templates/select.html.twig
+++ b/core/modules/system/templates/select.html.twig
@@ -12,4 +12,18 @@
* @ingroup themeable
*/
#}
-
+{% spaceless %}
+
+{% endspaceless %}
diff --git a/core/themes/classy/templates/form/select.html.twig b/core/themes/classy/templates/form/select.html.twig
index 51baa7a..3150bdc 100644
--- a/core/themes/classy/templates/form/select.html.twig
+++ b/core/themes/classy/templates/form/select.html.twig
@@ -10,4 +10,18 @@
* @see template_preprocess_select()
*/
#}
-
+{% spaceless %}
+
+{% endspaceless %}