From e7aa13886d02e77ef3202c59d44f02cab0c79eb7 Mon Sep 17 00:00:00 2001 From: MenKNas Date: Wed, 27 May 2026 09:59:36 +0300 Subject: [PATCH 1/6] Fix non-string Styles params crash in themes --- .changeset/non-string-styles-params.md | 5 ++ packages/content/src/layout/themes.test.ts | 72 ++++++++++++++++++++++ packages/content/src/layout/themes.ts | 26 ++++++-- 3 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 .changeset/non-string-styles-params.md diff --git a/.changeset/non-string-styles-params.md b/.changeset/non-string-styles-params.md new file mode 100644 index 0000000000..55184afcf6 --- /dev/null +++ b/.changeset/non-string-styles-params.md @@ -0,0 +1,5 @@ +--- +'@sitecore-content-sdk/content': patch +--- + +[content] Fix `TypeError: e.match is not a function` during build when LayoutService DetailedRenderingParams returns `Styles`, `CSSStyles` or `LibraryId` as objects instead of strings diff --git a/packages/content/src/layout/themes.test.ts b/packages/content/src/layout/themes.test.ts index 04d5a12a93..7f949cbdde 100644 --- a/packages/content/src/layout/themes.test.ts +++ b/packages/content/src/layout/themes.test.ts @@ -420,6 +420,78 @@ describe('themes', () => { })) ); }); + + // Layout Service may return Styles/CSSStyles/LibraryId params as objects + // rather than strings. Traversal must not crash on non-string values. + describe('non-string params (DetailedRenderingParams)', () => { + const detailedStylesObject = { + 'Allowed Renderings': [], + IsVerifiedStyle: { value: false }, + Value: { value: 'White-Background' }, + Icon: { value: '' }, + }; + + it('should not throw when params.Styles is an object', () => { + const run = () => + getDesignLibraryStylesheetLinks( + setBasicLayoutData(({ + componentName: 'styled', + params: { Styles: detailedStylesObject }, + } as unknown) as ComponentRendering), + sitecoreEdgeContextId + ); + + expect(run).to.not.throw(); + expect(run()).to.deep.equal([]); + }); + + it('should not throw when params.CSSStyles is an object', () => { + const run = () => + getDesignLibraryStylesheetLinks( + setBasicLayoutData(({ + componentName: 'styled', + params: { CSSStyles: detailedStylesObject }, + } as unknown) as ComponentRendering), + sitecoreEdgeContextId + ); + + expect(run).to.not.throw(); + expect(run()).to.deep.equal([]); + }); + + it('should not throw when params.LibraryId is an object', () => { + const run = () => + getDesignLibraryStylesheetLinks( + setBasicLayoutData(({ + componentName: 'styled', + params: { LibraryId: { Value: { value: 'bar' } } }, + } as unknown) as ComponentRendering), + sitecoreEdgeContextId + ); + + expect(run).to.not.throw(); + expect(run()).to.deep.equal([]); + }); + + it('should fall back to fields when params are objects', () => { + expect( + getDesignLibraryStylesheetLinks( + setBasicLayoutData(({ + componentName: 'styled', + params: { Styles: detailedStylesObject }, + fields: { + LibraryId: { + value: 'bar', + }, + }, + } as unknown) as ComponentRendering), + sitecoreEdgeContextId + ) + ).to.deep.equal([ + { href: getStylesheetUrl('bar', sitecoreEdgeContextId), rel: 'stylesheet' }, + ]); + }); + }); }); describe('getStylesheetUrl', () => { diff --git a/packages/content/src/layout/themes.ts b/packages/content/src/layout/themes.ts index 81db7a78b0..e0913c4b5e 100644 --- a/packages/content/src/layout/themes.ts +++ b/packages/content/src/layout/themes.ts @@ -52,6 +52,14 @@ const traversePlaceholder = (components: ComponentRendering[], ids: Set) }); }; +/** + * Returns the value if it is a string, otherwise undefined. + * @param {unknown} value value to check + * @returns {string | undefined} the string value, or undefined + */ +const asString = (value: unknown): string | undefined => + typeof value === 'string' ? value : undefined; + /** * Traverse component and children to add library ids * @param {RouteData | ComponentRendering | HtmlElementRendering} component component data @@ -60,19 +68,25 @@ const traversePlaceholder = (components: ComponentRendering[], ids: Set) const traverseComponent = (component: RouteData | ComponentRendering, ids: Set) => { let libraryId: string | undefined = undefined; if ('params' in component && component.params) { + const cssStylesParam = asString(component.params.CSSStyles); + const stylesParam = asString(component.params.Styles); + const libraryIdParam = asString(component.params.LibraryId); // LibraryID in css class name takes precedence over LibraryId attribute libraryId = - component.params.CSSStyles?.match(STYLES_LIBRARY_ID_REGEX)?.[1] || - component.params.Styles?.match(STYLES_LIBRARY_ID_REGEX)?.[1] || - component.params.LibraryId || + cssStylesParam?.match(STYLES_LIBRARY_ID_REGEX)?.[1] || + stylesParam?.match(STYLES_LIBRARY_ID_REGEX)?.[1] || + libraryIdParam || undefined; } // if params are empty we try to fall back to data source if (!libraryId && 'fields' in component && component.fields) { + const cssStylesField = asString(getFieldValue(component.fields, 'CSSStyles', '')); + const stylesField = asString(getFieldValue(component.fields, 'Styles', '')); + const libraryIdField = asString(getFieldValue(component.fields, 'LibraryId', '')); libraryId = - getFieldValue(component.fields, 'CSSStyles', '').match(STYLES_LIBRARY_ID_REGEX)?.[1] || - getFieldValue(component.fields, 'Styles', '').match(STYLES_LIBRARY_ID_REGEX)?.[1] || - getFieldValue(component.fields, 'LibraryId', '') || + cssStylesField?.match(STYLES_LIBRARY_ID_REGEX)?.[1] || + stylesField?.match(STYLES_LIBRARY_ID_REGEX)?.[1] || + libraryIdField || undefined; } From 5cec8ea079498670cdd40c215d95422aaf279da1 Mon Sep 17 00:00:00 2001 From: MenKNas Date: Wed, 27 May 2026 18:03:52 +0300 Subject: [PATCH 2/6] Make tests more concrete --- packages/content/src/layout/themes.test.ts | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/packages/content/src/layout/themes.test.ts b/packages/content/src/layout/themes.test.ts index 7f949cbdde..466ea7d409 100644 --- a/packages/content/src/layout/themes.test.ts +++ b/packages/content/src/layout/themes.test.ts @@ -491,6 +491,55 @@ describe('themes', () => { { href: getStylesheetUrl('bar', sitecoreEdgeContextId), rel: 'stylesheet' }, ]); }); + + it('should not throw when traversing nested placeholders with object params', () => { + const layoutData = { + sitecore: { + context: {}, + route: { + name: 'home', + placeholders: { + main: [ + { + componentName: 'header', + params: { Styles: detailedStylesObject }, + placeholders: { + content: [ + { + componentName: 'body', + params: { CSSStyles: detailedStylesObject, LibraryId: detailedStylesObject }, + }, + ], + }, + }, + ], + }, + }, + }, + }; + + const run = () => getDesignLibraryStylesheetLinks(layoutData, sitecoreEdgeContextId); + + expect(run).to.not.throw(); + expect(run()).to.deep.equal([]); + }); + + it('should still resolve library id from string CSSStyles when Styles param is an object', () => { + expect( + getDesignLibraryStylesheetLinks( + setBasicLayoutData(({ + componentName: 'styled', + params: { + CSSStyles: '-library--foo', + Styles: detailedStylesObject, + }, + } as unknown) as ComponentRendering), + sitecoreEdgeContextId + ) + ).to.deep.equal([ + { href: getStylesheetUrl('foo', sitecoreEdgeContextId), rel: 'stylesheet' }, + ]); + }); }); }); From 64960f4797241ff4abee332912d073ad83cb2649 Mon Sep 17 00:00:00 2001 From: MenKNas Date: Wed, 3 Jun 2026 16:57:58 +0300 Subject: [PATCH 3/6] Add DetailedRenderingParams normalization for styles --- .changeset/non-string-styles-params.md | 2 +- packages/content/src/layout/index.ts | 1 + packages/content/src/layout/themes.test.ts | 43 ++++++++++++- packages/content/src/layout/themes.ts | 32 +++++----- packages/content/src/layout/utils.test.ts | 37 +++++++++++ packages/content/src/layout/utils.ts | 61 +++++++++++++++++++ .../Placeholder/placeholder-utils.test.tsx | 55 ++++++++++++++++- .../Placeholder/placeholder-utils.tsx | 17 +++--- 8 files changed, 221 insertions(+), 27 deletions(-) diff --git a/.changeset/non-string-styles-params.md b/.changeset/non-string-styles-params.md index 55184afcf6..6493101519 100644 --- a/.changeset/non-string-styles-params.md +++ b/.changeset/non-string-styles-params.md @@ -2,4 +2,4 @@ '@sitecore-content-sdk/content': patch --- -[content] Fix `TypeError: e.match is not a function` during build when LayoutService DetailedRenderingParams returns `Styles`, `CSSStyles` or `LibraryId` as objects instead of strings +[content] Fix build crash and normalize DetailedRenderingParams object/JSON values for `Styles`, `CSSStyles`, `LibraryId`, and `GridParameters` rendering params diff --git a/packages/content/src/layout/index.ts b/packages/content/src/layout/index.ts index 2c0d6b154d..7e33f17ef0 100644 --- a/packages/content/src/layout/index.ts +++ b/packages/content/src/layout/index.ts @@ -23,6 +23,7 @@ export { export { getFieldValue, + getRenderingParamString, getChildPlaceholder, isFieldValueEmpty, isDynamicPlaceholder, diff --git a/packages/content/src/layout/themes.test.ts b/packages/content/src/layout/themes.test.ts index 466ea7d409..182ec3398e 100644 --- a/packages/content/src/layout/themes.test.ts +++ b/packages/content/src/layout/themes.test.ts @@ -470,7 +470,43 @@ describe('themes', () => { ); expect(run).to.not.throw(); - expect(run()).to.deep.equal([]); + expect(run()).to.deep.equal([ + { href: getStylesheetUrl('bar', sitecoreEdgeContextId), rel: 'stylesheet' }, + ]); + }); + + it('should resolve library id from object Styles Value.value', () => { + expect( + getDesignLibraryStylesheetLinks( + setBasicLayoutData(({ + componentName: 'styled', + params: { + Styles: { + Value: { value: '-library--foo White-Background' }, + }, + }, + } as unknown) as ComponentRendering), + sitecoreEdgeContextId + ) + ).to.deep.equal([ + { href: getStylesheetUrl('foo', sitecoreEdgeContextId), rel: 'stylesheet' }, + ]); + }); + + it('should resolve library id from JSON string Styles param', () => { + expect( + getDesignLibraryStylesheetLinks( + setBasicLayoutData(({ + componentName: 'styled', + params: { + Styles: '{"Value":{"value":"-library--foo"}}', + }, + } as unknown) as ComponentRendering), + sitecoreEdgeContextId + ) + ).to.deep.equal([ + { href: getStylesheetUrl('foo', sitecoreEdgeContextId), rel: 'stylesheet' }, + ]); }); it('should fall back to fields when params are objects', () => { @@ -507,7 +543,10 @@ describe('themes', () => { content: [ { componentName: 'body', - params: { CSSStyles: detailedStylesObject, LibraryId: detailedStylesObject }, + params: { + CSSStyles: detailedStylesObject, + LibraryId: { IsVerifiedStyle: { value: false } }, + }, }, ], }, diff --git a/packages/content/src/layout/themes.ts b/packages/content/src/layout/themes.ts index e0913c4b5e..12f8938820 100644 --- a/packages/content/src/layout/themes.ts +++ b/packages/content/src/layout/themes.ts @@ -1,6 +1,12 @@ import { constants } from '@sitecore-content-sdk/core'; import { normalizeUrl } from '@sitecore-content-sdk/core/tools'; -import { ComponentRendering, LayoutServiceData, RouteData, getFieldValue } from '.'; +import { + ComponentRendering, + LayoutServiceData, + RouteData, + getFieldValue, + getRenderingParamString, +} from '.'; import { HTMLLink } from '../models'; /** @@ -52,14 +58,6 @@ const traversePlaceholder = (components: ComponentRendering[], ids: Set) }); }; -/** - * Returns the value if it is a string, otherwise undefined. - * @param {unknown} value value to check - * @returns {string | undefined} the string value, or undefined - */ -const asString = (value: unknown): string | undefined => - typeof value === 'string' ? value : undefined; - /** * Traverse component and children to add library ids * @param {RouteData | ComponentRendering | HtmlElementRendering} component component data @@ -68,9 +66,9 @@ const asString = (value: unknown): string | undefined => const traverseComponent = (component: RouteData | ComponentRendering, ids: Set) => { let libraryId: string | undefined = undefined; if ('params' in component && component.params) { - const cssStylesParam = asString(component.params.CSSStyles); - const stylesParam = asString(component.params.Styles); - const libraryIdParam = asString(component.params.LibraryId); + const cssStylesParam = getRenderingParamString(component.params.CSSStyles); + const stylesParam = getRenderingParamString(component.params.Styles); + const libraryIdParam = getRenderingParamString(component.params.LibraryId); // LibraryID in css class name takes precedence over LibraryId attribute libraryId = cssStylesParam?.match(STYLES_LIBRARY_ID_REGEX)?.[1] || @@ -80,9 +78,13 @@ const traverseComponent = (component: RouteData | ComponentRendering, ids: Set { + describe('getRenderingParamString', () => { + it('should return plain string params unchanged', () => { + expect(getRenderingParamString('col-lg-6')).to.equal('col-lg-6'); + expect(getRenderingParamString('-library--foo')).to.equal('-library--foo'); + }); + + it('should extract Value.value from DetailedRenderingParams objects', () => { + expect( + getRenderingParamString({ + 'Allowed Renderings': [], + IsVerifiedStyle: { value: false }, + Value: { value: 'White-Background' }, + Icon: { value: '' }, + }) + ).to.equal('White-Background'); + }); + + it('should extract value from simple object wrappers', () => { + expect(getRenderingParamString({ value: 'bar' })).to.equal('bar'); + }); + + it('should extract Value.value from JSON string params', () => { + expect( + getRenderingParamString('{"Value":{"value":"White-Background"},"IsVerifiedStyle":{"value":false}}') + ).to.equal('White-Background'); + }); + + it('should return undefined for unextractable values', () => { + expect(getRenderingParamString(undefined)).to.be.undefined; + expect(getRenderingParamString(null)).to.be.undefined; + expect(getRenderingParamString({})).to.be.undefined; + expect(getRenderingParamString({ Value: { value: 42 } })).to.be.undefined; + expect(getRenderingParamString('{"foo":"bar"}')).to.be.undefined; + }); + }); + describe('getFieldValue', () => { const fields = { crop: { diff --git a/packages/content/src/layout/utils.ts b/packages/content/src/layout/utils.ts index 1a55c80890..c1cd743415 100644 --- a/packages/content/src/layout/utils.ts +++ b/packages/content/src/layout/utils.ts @@ -1,6 +1,67 @@ /* eslint-disable no-redeclare */ import { ComponentRendering, ComponentFields, Field, GenericFieldValue } from './models'; +const extractDetailedRenderingParamValue = (value: Record): string | undefined => { + const detailedValue = value.Value; + if ( + detailedValue && + typeof detailedValue === 'object' && + detailedValue !== null && + 'value' in detailedValue + ) { + const nestedValue = (detailedValue as { value: unknown }).value; + if (typeof nestedValue === 'string') { + return nestedValue; + } + } + + if (typeof value.value === 'string') { + return value.value; + } + + return undefined; +}; + +/** + * Normalizes a rendering param value to a string. + * Layout Service may return DetailedRenderingParams as objects or JSON strings + * instead of plain strings (e.g. Styles, CSSStyles, GridParameters). + * @param {unknown} value rendering param value + * @returns {string | undefined} normalized string value, or undefined when not extractable + * @public + */ +export function getRenderingParamString(value: unknown): string | undefined { + if (value === null || value === undefined) { + return undefined; + } + + if (typeof value === 'string') { + if (value.startsWith('{')) { + try { + const parsed: unknown = JSON.parse(value); + if (parsed && typeof parsed === 'object') { + const extracted = extractDetailedRenderingParamValue(parsed as Record); + if (extracted !== undefined) { + return extracted; + } + + return undefined; + } + } catch { + // Not JSON — treat as a plain string param value. + } + } + + return value; + } + + if (typeof value === 'object') { + return extractDetailedRenderingParamValue(value as Record); + } + + return undefined; +} + /** * Safely extracts a field value from a rendering or fields object. * Null will be returned if the field is not defined. diff --git a/packages/react/src/components/Placeholder/placeholder-utils.test.tsx b/packages/react/src/components/Placeholder/placeholder-utils.test.tsx index 0b44218f18..29fd140945 100644 --- a/packages/react/src/components/Placeholder/placeholder-utils.test.tsx +++ b/packages/react/src/components/Placeholder/placeholder-utils.test.tsx @@ -150,7 +150,7 @@ describe('placeholder-utils', () => { const result = getSXAParams(rendering); expect(result).to.deep.equal({ - styles: 'col-lg-8 ', + styles: 'col-lg-8', }); }); @@ -167,7 +167,7 @@ describe('placeholder-utils', () => { const result = getSXAParams(rendering); expect(result).to.deep.equal({ - styles: ' custom-styles', + styles: 'custom-styles', }); }); @@ -181,6 +181,57 @@ describe('placeholder-utils', () => { expect(result).to.deep.equal({ styles: '' }); }); + + it('should extract styles from DetailedRenderingParams object', () => { + const rendering = ({ + componentName: 'TestComponent', + uid: 'test-uid', + params: { + Styles: { + Value: { value: 'White-Background' }, + }, + }, + } as unknown) as ComponentRendering; + + const result = getSXAParams(rendering); + + expect(result).to.deep.equal({ + styles: 'White-Background', + }); + }); + + it('should combine object GridParameters and Styles params', () => { + const rendering = ({ + componentName: 'TestComponent', + uid: 'test-uid', + params: { + GridParameters: { Value: { value: 'col-lg-6' } }, + Styles: { Value: { value: 'White-Background' } }, + }, + } as unknown) as ComponentRendering; + + const result = getSXAParams(rendering); + + expect(result).to.deep.equal({ + styles: 'col-lg-6 White-Background', + }); + }); + + it('should extract styles from JSON string DetailedRenderingParams', () => { + const rendering: ComponentRendering = { + componentName: 'TestComponent', + uid: 'test-uid', + params: { + Styles: '{"Value":{"value":"White-Background"}}', + }, + }; + + const result = getSXAParams(rendering); + + expect(result).to.deep.equal({ + styles: 'White-Background', + }); + }); }); describe('getChildComponentProps', () => { diff --git a/packages/react/src/components/Placeholder/placeholder-utils.tsx b/packages/react/src/components/Placeholder/placeholder-utils.tsx index 3d52324e9c..ae3bcb8310 100644 --- a/packages/react/src/components/Placeholder/placeholder-utils.tsx +++ b/packages/react/src/components/Placeholder/placeholder-utils.tsx @@ -6,6 +6,7 @@ import { RouteData, isDynamicPlaceholder, getDynamicPlaceholderPattern, + getRenderingParamString, } from '@sitecore-content-sdk/content/layout'; import { HIDDEN_RENDERING_NAME } from '@sitecore-content-sdk/content'; import { HiddenRendering } from '../HiddenRendering'; @@ -81,16 +82,18 @@ export const getPlaceholderRenderings = ( * @param {ComponentRendering} rendering rendering object * @returns {object} converted SXA params */ -export const getSXAParams = (rendering: ComponentRendering) => { +export const getSXAParams = (rendering: ComponentRendering): { styles: string } | undefined => { if (!rendering.params) return { styles: '' }; - const { GridParameters, Styles } = rendering.params; + const gridParameters = getRenderingParamString(rendering.params.GridParameters) ?? ''; + const styles = getRenderingParamString(rendering.params.Styles) ?? ''; + const combinedStyles = [gridParameters, styles].filter(Boolean).join(' '); - return ( - (GridParameters || Styles) && { - styles: `${GridParameters || ''} ${Styles || ''}`, - } - ); + if (!combinedStyles) { + return undefined; + } + + return { styles: combinedStyles }; }; /** From 7375070dda2fcd3a8f0d549db692283859d9ee3e Mon Sep 17 00:00:00 2001 From: MenKNas Date: Wed, 3 Jun 2026 17:16:21 +0300 Subject: [PATCH 4/6] Fix api extractor issue --- packages/content/api/content-sdk-content.api.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/content/api/content-sdk-content.api.md b/packages/content/api/content-sdk-content.api.md index 6015d42826..b4fd5c84ad 100644 --- a/packages/content/api/content-sdk-content.api.md +++ b/packages/content/api/content-sdk-content.api.md @@ -610,6 +610,9 @@ export function getPersonalizedRewrite(pathname: string, variantIds: string[]): // @public export function getPersonalizedRewriteData(pathname: string): PersonalizedRewriteData; +// @public +export function getRenderingParamString(value: unknown): string | undefined; + // @public const getRequiredParams: (qs: { [key: string]: string | undefined; From 645c496063741aeb505924c49af7cf8fb60850e0 Mon Sep 17 00:00:00 2001 From: MenKNas Date: Thu, 4 Jun 2026 14:24:06 +0300 Subject: [PATCH 5/6] Make util internal --- packages/content/api/content-sdk-content.api.md | 2 +- packages/content/src/layout/utils.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/content/api/content-sdk-content.api.md b/packages/content/api/content-sdk-content.api.md index b4fd5c84ad..57eff891e8 100644 --- a/packages/content/api/content-sdk-content.api.md +++ b/packages/content/api/content-sdk-content.api.md @@ -610,7 +610,7 @@ export function getPersonalizedRewrite(pathname: string, variantIds: string[]): // @public export function getPersonalizedRewriteData(pathname: string): PersonalizedRewriteData; -// @public +// @internal export function getRenderingParamString(value: unknown): string | undefined; // @public diff --git a/packages/content/src/layout/utils.ts b/packages/content/src/layout/utils.ts index c1cd743415..ed0684664a 100644 --- a/packages/content/src/layout/utils.ts +++ b/packages/content/src/layout/utils.ts @@ -28,7 +28,7 @@ const extractDetailedRenderingParamValue = (value: Record): str * instead of plain strings (e.g. Styles, CSSStyles, GridParameters). * @param {unknown} value rendering param value * @returns {string | undefined} normalized string value, or undefined when not extractable - * @public + * @internal */ export function getRenderingParamString(value: unknown): string | undefined { if (value === null || value === undefined) { From 964c18002a9eeb5d793478ff71a462b1e4bfd445 Mon Sep 17 00:00:00 2001 From: MenKNas Date: Thu, 4 Jun 2026 17:04:10 +0300 Subject: [PATCH 6/6] Remove stringified json parser from csdk --- .changeset/non-string-styles-params.md | 2 +- packages/content/src/layout/themes.test.ts | 16 --------------- packages/content/src/layout/utils.test.ts | 7 ------- packages/content/src/layout/utils.ts | 20 ++----------------- .../Placeholder/placeholder-utils.test.tsx | 15 -------------- 5 files changed, 3 insertions(+), 57 deletions(-) diff --git a/.changeset/non-string-styles-params.md b/.changeset/non-string-styles-params.md index 6493101519..1eab424281 100644 --- a/.changeset/non-string-styles-params.md +++ b/.changeset/non-string-styles-params.md @@ -2,4 +2,4 @@ '@sitecore-content-sdk/content': patch --- -[content] Fix build crash and normalize DetailedRenderingParams object/JSON values for `Styles`, `CSSStyles`, `LibraryId`, and `GridParameters` rendering params +[content] Fix build crash and normalize DetailedRenderingParams object values for `Styles`, `CSSStyles`, `LibraryId`, and `GridParameters` rendering params diff --git a/packages/content/src/layout/themes.test.ts b/packages/content/src/layout/themes.test.ts index 182ec3398e..5f521946bf 100644 --- a/packages/content/src/layout/themes.test.ts +++ b/packages/content/src/layout/themes.test.ts @@ -493,22 +493,6 @@ describe('themes', () => { ]); }); - it('should resolve library id from JSON string Styles param', () => { - expect( - getDesignLibraryStylesheetLinks( - setBasicLayoutData(({ - componentName: 'styled', - params: { - Styles: '{"Value":{"value":"-library--foo"}}', - }, - } as unknown) as ComponentRendering), - sitecoreEdgeContextId - ) - ).to.deep.equal([ - { href: getStylesheetUrl('foo', sitecoreEdgeContextId), rel: 'stylesheet' }, - ]); - }); - it('should fall back to fields when params are objects', () => { expect( getDesignLibraryStylesheetLinks( diff --git a/packages/content/src/layout/utils.test.ts b/packages/content/src/layout/utils.test.ts index 61738e1e0c..fc3fe08742 100644 --- a/packages/content/src/layout/utils.test.ts +++ b/packages/content/src/layout/utils.test.ts @@ -33,18 +33,11 @@ describe('core layout utils', () => { expect(getRenderingParamString({ value: 'bar' })).to.equal('bar'); }); - it('should extract Value.value from JSON string params', () => { - expect( - getRenderingParamString('{"Value":{"value":"White-Background"},"IsVerifiedStyle":{"value":false}}') - ).to.equal('White-Background'); - }); - it('should return undefined for unextractable values', () => { expect(getRenderingParamString(undefined)).to.be.undefined; expect(getRenderingParamString(null)).to.be.undefined; expect(getRenderingParamString({})).to.be.undefined; expect(getRenderingParamString({ Value: { value: 42 } })).to.be.undefined; - expect(getRenderingParamString('{"foo":"bar"}')).to.be.undefined; }); }); diff --git a/packages/content/src/layout/utils.ts b/packages/content/src/layout/utils.ts index ed0684664a..a4ae3e64f4 100644 --- a/packages/content/src/layout/utils.ts +++ b/packages/content/src/layout/utils.ts @@ -24,8 +24,8 @@ const extractDetailedRenderingParamValue = (value: Record): str /** * Normalizes a rendering param value to a string. - * Layout Service may return DetailedRenderingParams as objects or JSON strings - * instead of plain strings (e.g. Styles, CSSStyles, GridParameters). + * Layout Service may return DetailedRenderingParams as objects instead of plain + * strings (e.g. Styles, CSSStyles, GridParameters). * @param {unknown} value rendering param value * @returns {string | undefined} normalized string value, or undefined when not extractable * @internal @@ -36,22 +36,6 @@ export function getRenderingParamString(value: unknown): string | undefined { } if (typeof value === 'string') { - if (value.startsWith('{')) { - try { - const parsed: unknown = JSON.parse(value); - if (parsed && typeof parsed === 'object') { - const extracted = extractDetailedRenderingParamValue(parsed as Record); - if (extracted !== undefined) { - return extracted; - } - - return undefined; - } - } catch { - // Not JSON — treat as a plain string param value. - } - } - return value; } diff --git a/packages/react/src/components/Placeholder/placeholder-utils.test.tsx b/packages/react/src/components/Placeholder/placeholder-utils.test.tsx index 29fd140945..935484453e 100644 --- a/packages/react/src/components/Placeholder/placeholder-utils.test.tsx +++ b/packages/react/src/components/Placeholder/placeholder-utils.test.tsx @@ -217,21 +217,6 @@ describe('placeholder-utils', () => { }); }); - it('should extract styles from JSON string DetailedRenderingParams', () => { - const rendering: ComponentRendering = { - componentName: 'TestComponent', - uid: 'test-uid', - params: { - Styles: '{"Value":{"value":"White-Background"}}', - }, - }; - - const result = getSXAParams(rendering); - - expect(result).to.deep.equal({ - styles: 'White-Background', - }); - }); }); describe('getChildComponentProps', () => {