You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This could be false or null when using the twig ternary operator
67
+
if(!$attributes) {
68
+
continue;
69
+
}
70
+
71
+
if (!is_iterable($attributes)) {
72
+
thrownewRuntimeError(sprintf('"%s" only works with mappings or "Traversable", got "%s" for argument %d.', self::class, \gettype($attributes), $attributeGroupCount));
73
+
}
74
+
75
+
// Alternative to is_iterable check above, cast the attributes to an array
76
+
// This would produce weird results but would not throw an error
77
+
// $attributes = (array)$attributes;
78
+
79
+
// data and aria arrays are expanded into data-* and aria-* attributes
80
+
$expanded = [];
81
+
foreach ($attributesas$key => $value) {
82
+
if (in_array($key, ['data', 'aria'])) {
83
+
$value = (array)$value;
84
+
foreach ($valueas$k => $v) {
85
+
$k = $key . '-' . $k;
86
+
$expanded[$k] = $v;
87
+
}
88
+
continue;
89
+
}
90
+
$expanded[$key] = $value;
91
+
}
92
+
93
+
// Reset the attributes array to the flattened version
94
+
$attributes = $expanded;
95
+
96
+
foreach ($attributesas$key => $value) {
97
+
98
+
// Treat class and data-controller attributes as arrays
0 commit comments