Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
de66aa93
Commit
de66aa93
authored
Jan 20, 2023
by
Nathaniel Catchpole
Browse files
Issue
#3333858
by miiimooo, larowlan: Blocks that have #attached set removed after upgrade
parent
aa373a88
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/Render/Element.php
View file @
de66aa93
...
...
@@ -187,7 +187,7 @@ public static function setAttributes(array &$element, array $map) {
/**
* Indicates whether the given element is empty.
*
* An element that only has #cache
,
#weight
, or #attached
set is considered
* An element that only has #cache
or
#weight set is considered
* empty, because it will render to the empty string.
*
* @param array $elements
...
...
@@ -197,7 +197,7 @@ public static function setAttributes(array &$element, array $map) {
* Whether the given element is empty.
*/
public
static
function
isEmpty
(
array
$elements
)
{
return
\
array_diff
(
\
array_keys
(
$elements
),
[
'#cache'
,
'#weight'
,
'#attached'
])
===
[];
return
\
array_diff
(
\
array_keys
(
$elements
),
[
'#cache'
,
'#weight'
])
===
[];
}
}
core/tests/Drupal/Tests/Core/Render/ElementTest.php
View file @
de66aa93
...
...
@@ -188,13 +188,13 @@ public function testIsEmpty(array $element, $expected) {
public
function
providerTestIsEmpty
()
{
return
[
[[],
TRUE
],
[[
'#attached'
=>
[]],
TRU
E
],
[[
'#attached'
=>
[]],
FALS
E
],
[[
'#cache'
=>
[]],
TRUE
],
[[
'#weight'
=>
[]],
TRUE
],
// Variations.
[[
'#attached'
=>
[],
'#cache'
=>
[]],
TRU
E
],
[[
'#attached'
=>
[],
'#weight'
=>
[]],
TRU
E
],
[[
'#attached'
=>
[],
'#weight'
=>
[],
'#cache'
=>
[]],
TRU
E
],
[[
'#attached'
=>
[],
'#cache'
=>
[]],
FALS
E
],
[[
'#attached'
=>
[],
'#weight'
=>
[]],
FALS
E
],
[[
'#attached'
=>
[],
'#weight'
=>
[],
'#cache'
=>
[]],
FALS
E
],
[[
'#cache'
=>
[],
'#weight'
=>
[]],
TRUE
],
[[
'#cache'
=>
[],
'#weight'
=>
[],
'#any_other_property'
=>
[]],
FALSE
],
[
...
...
@@ -207,9 +207,9 @@ public function providerTestIsEmpty() {
FALSE
,
],
// Cover sorting.
[[
'#cache'
=>
[],
'#weight'
=>
[],
'#attached'
=>
[]],
TRU
E
],
[[
'#attached'
=>
[],
'#cache'
=>
[],
'#weight'
=>
[]],
TRUE
],
[[
'#weight'
=>
[],
'#attached'
=>
[],
'#cache'
=>
[]],
TRUE
],
[[
'#cache'
=>
[],
'#weight'
=>
[],
'#attached'
=>
[]],
FALS
E
],
[[
'#cache'
=>
[],
'#weight'
=>
[]],
TRUE
],
[[
'#weight'
=>
[],
'#cache'
=>
[]],
TRUE
],
[[
'#cache'
=>
[]],
TRUE
],
[[
'#cache'
=>
[
'tags'
=>
[
'foo'
]]],
TRUE
],
...
...
Nathaniel Catchpole
@catch
mentioned in commit
943b8f72
·
Jan 20, 2023
mentioned in commit
943b8f72
mentioned in commit 943b8f72d853a52956a181bd6ccaf9d466bc6ce9
Toggle commit list
Nathaniel Catchpole
@catch
mentioned in commit
8929ebe8
·
Jan 20, 2023
mentioned in commit
8929ebe8
mentioned in commit 8929ebe86f354c310ce6e408f7484c9928c6582a
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment