Skip to content

feat: support setting non-primitive values as props instead of attr#3

Closed
ronald-urbina wants to merge 1 commit intomuxinc:mainfrom
ronald-urbina:feat/use-props-for-nonprimitive-values
Closed

feat: support setting non-primitive values as props instead of attr#3
ronald-urbina wants to merge 1 commit intomuxinc:mainfrom
ronald-urbina:feat/use-props-for-nonprimitive-values

Conversation

@ronald-urbina
Copy link
Copy Markdown

This PR updates the createComponent logic to ensure that when a web component attribute is a non-primitive (e.g. object, array), it is assigned directly as a property on the custom element.

This change addresses muxinc/media-chrome#1120, where the attribute rates in react its expected to be an array and was ignored by the current implementation.

@luwes
Copy link
Copy Markdown
Collaborator

luwes commented May 14, 2025

Closing this because the fix ended up being serializing the prop value. This was and edge case because in most cases when the property value is a complex value it doesn't have a reflecting attribute and the corresponding attribute wouldn't be observed. In this case ce-la-react correctly sets it as a property.

!elementClass.observedAttributes?.some((attr) => attr === attrName)

@luwes luwes closed this May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants