Unverified Commit a9262c1b authored by Lee Rowlands's avatar Lee Rowlands Committed by Lee Rowlands
Browse files

Issue #3260042 by larowlan, rikki_iki: Add support for setting attributes other than class

parent 45407b94
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -37,6 +37,16 @@ class ClassyLayout extends LayoutDefault implements PluginFormInterface {
          }
        }
      }
      if ($definition['attributes'] ?? FALSE) {
        $class_set = (array) $class_set;
        foreach ($class_set as $class) {
          if ($attributes = ($definition['attributes'][$class] ?? FALSE)) {
            foreach ($attributes as $attribute => $attribute_value) {
              $build['#attributes'][$attribute] = $attribute_value;
            }
          }
        }
      }
    }
    return $build;
  }
+3 −0
Original line number Diff line number Diff line
@@ -14,6 +14,9 @@ test_layout:
      region_classes:
        'background--wave-dark background--primary-light':
          content: 'a-region-class'
      attributes:
        'background--wave-dark background--primary-light':
          data-some-attribute: foo
    spacing:
      label: 'Spacing'
      multiple: false
+2 −0
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ class LayoutSectionClassesTest extends LayoutBuilderCompatibilityTestBase {
    $crawler = new Crawler($rendered);
    // Assert region classes work as expected.
    $this->assertCount(1, $crawler->filter('.some-region-classes.a-region-class'));
    // Assert attributes work as expected.
    $this->assertCount(1, $crawler->filter('.background--wave-dark.background--primary-light[data-some-attribute="foo"]'));
  }

  /**