Skip to content

Commit

Permalink
Add explanation of order importance to inline comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Nov 20, 2024
1 parent 14bae35 commit 8b92b76
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/compat/wordpress-6.8/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ function gutenberg_stabilize_experimental_block_supports( $args ) {
* are defined in to determine the final value.
* - If config is an array, merge the arrays in their order of definition.
* - If config is not an array, use the value defined last.
*
* The reason for preferring the last defined key is that after filters
* are applied, the last inserted key is likely the most up-to-date value.
* We cannot determine with certainty which value was "last modified" so
* the insertion order is the best guess. The extreme edge case of multiple
* filters tweaking the same support property will become less over time as
* extenders migrate existing blocks and plugins to stable keys.
*/
if ( $support !== $stable_support_key && isset( $args['supports'][ $stable_support_key ] ) ) {
$key_positions = array_flip( array_keys( $args['supports'] ) );
Expand Down
7 changes: 7 additions & 0 deletions packages/blocks/src/store/process-block-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ function stabilizeSupports( rawSupports ) {
* are defined in to determine the final value.
* - If config is an array, merge the arrays in their order of definition.
* - If config is not an array, use the value defined last.
*
* The reason for preferring the last defined key is that after filters
* are applied, the last inserted key is likely the most up-to-date value.
* We cannot determine with certainty which value was "last modified" so
* the insertion order is the best guess. The extreme edge case of multiple
* filters tweaking the same support property will become less over time as
* extenders migrate existing blocks and plugins to stable keys.
*/
if (
support !== stableSupportKey &&
Expand Down

0 comments on commit 8b92b76

Please sign in to comment.