From 5cdeb7fd357298f15e7ae29b14412d97bdc7c656 Mon Sep 17 00:00:00 2001 From: Brandy Smith Date: Fri, 27 Feb 2026 12:53:49 -0500 Subject: [PATCH] feat(item-divider): add inner and container parts (#30928) Issue number: N/A --------- ## What is the current behavior? The inner structural elements of item-divider are not exposed as shadow parts, preventing users from being able to customize their styles directly. ## What is the new behavior? - Exposes `inner` and `container` shadow parts - Adds e2e test coverage for customizing the shadow parts ## Does this introduce a breaking change? - [ ] Yes - [x] No --------- Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com> --- core/api.txt | 2 + .../components/item-divider/item-divider.tsx | 7 ++- .../test/custom/item-divider.e2e.ts | 57 +++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 core/src/components/item-divider/test/custom/item-divider.e2e.ts diff --git a/core/api.txt b/core/api.txt index 7d28f5139c..fc57c79d1c 100644 --- a/core/api.txt +++ b/core/api.txt @@ -968,6 +968,8 @@ ion-item-divider,css-prop,--padding-start,ios ion-item-divider,css-prop,--padding-start,md ion-item-divider,css-prop,--padding-top,ios ion-item-divider,css-prop,--padding-top,md +ion-item-divider,part,container +ion-item-divider,part,inner ion-item-group,none diff --git a/core/src/components/item-divider/item-divider.tsx b/core/src/components/item-divider/item-divider.tsx index ac449ffa3a..0febf39330 100644 --- a/core/src/components/item-divider/item-divider.tsx +++ b/core/src/components/item-divider/item-divider.tsx @@ -11,6 +11,9 @@ import type { Color } from '../../interface'; * @slot - Content is placed between the named slots if provided without a slot. * @slot start - Content is placed to the left of the divider text in LTR, and to the right in RTL. * @slot end - Content is placed to the right of the divider text in LTR, and to the left in RTL. + * + * @part inner - The inner wrapper element that arranges the divider content. + * @part container - The wrapper element that contains the default slot. */ @Component({ tag: 'ion-item-divider', @@ -50,8 +53,8 @@ export class ItemDivider implements ComponentInterface { })} > -
-
+
+
diff --git a/core/src/components/item-divider/test/custom/item-divider.e2e.ts b/core/src/components/item-divider/test/custom/item-divider.e2e.ts new file mode 100644 index 0000000000..497d607a2b --- /dev/null +++ b/core/src/components/item-divider/test/custom/item-divider.e2e.ts @@ -0,0 +1,57 @@ +import { expect } from '@playwright/test'; +import { configs, test } from '@utils/test/playwright'; + +/** + * This behavior does not vary across modes/directions + */ +configs({ directions: ['ltr'], modes: ['md'] }).forEach(({ title, config }) => { + test.describe(title('item-divider: custom'), () => { + test.describe('CSS shadow parts', () => { + test('should be able to customize inner part', async ({ page }) => { + await page.setContent( + ` + + + Divider + `, + config + ); + + const divider = page.locator('ion-item-divider'); + const backgroundColor = await divider.evaluate((el) => { + const shadowRoot = el.shadowRoot; + const inner = shadowRoot?.querySelector('.item-divider-inner'); + return inner ? window.getComputedStyle(inner).backgroundColor : ''; + }); + expect(backgroundColor).toBe('rgb(255, 0, 0)'); + }); + + test('should be able to customize container part', async ({ page }) => { + await page.setContent( + ` + + + Divider + `, + config + ); + + const divider = page.locator('ion-item-divider'); + const backgroundColor = await divider.evaluate((el) => { + const shadowRoot = el.shadowRoot; + const container = shadowRoot?.querySelector('.item-divider-wrapper'); + return container ? window.getComputedStyle(container).backgroundColor : ''; + }); + expect(backgroundColor).toBe('rgb(0, 128, 0)'); + }); + }); + }); +});