- Issue created by @pdureau
- Merge request !11649Merge component ['#attributes'] with the ['#props']['attributes']. → (Closed) created by dipakmdhrm
- 🇫🇷France goz
Looks great.
What's about a test to confirm props attributes will keep its values in case keys exist in both.$build = [ '#type' => 'component', '#component' => 'sdc_theme_test:my-card', '#props' => [ 'header' => 'Drupal.org', 'attributes' => new Attribute([ 'foo' => 'bar', ]), ], '#attributes' => [ 'foo => 'third', ], ];
I think in this case, foo should still be bar.
And what's about attribute with array like classes for example ?
$build = [ '#type' => 'component', '#component' => 'sdc_theme_test:my-card', '#props' => [ 'header' => 'Drupal.org', 'attributes' => new Attribute([ 'foo' => ['bar', 'ter'], ]), ], '#attributes' => [ 'foo' => ['quater'], ], ];
- 🇫🇷France Grimreaper France 🇫🇷
MR rebased and updated regarding comment 7.
- 🇫🇷France pdureau Paris
Oops, it was not something to merge yet. Merge train cancelled.
- Assigned to pdureau
- Status changed to Needs review
3 months ago 9:36pm 6 July 2025 - 🇫🇷France pdureau Paris
Thanks Steven. I rebase and check the pipeline first. Review later.
- 🇺🇸United States smustgrave
Ran the test-only feature
1) Drupal\KernelTests\Components\ComponentRenderTest::testRender <html><body><div id="sdc-wrapper"><div foo="bar" data-component-id="sdc_theme_test:my-card"> <h2 class="component--my-card__header">Drupal.org</h2> <div class="component--my-card__body"> Default contents for a card </div> </div> </div> </body></html> Failed asserting that an object is not empty. /builds/issue/drupal-3515506/core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php:302 /builds/issue/drupal-3515506/core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php:44 FAILURES! Tests: 3, Assertions: 29, Failures: 1. Exiting with EXIT_CODE=1
Which shows the coverage. Don't see any open threads but want to leave assigned to pdureau :)
Would it be worth a change record to announce things like |add_class now work with attributes?