lwc icon indicating copy to clipboard operation
lwc copied to clipboard

Non-standard ARIA attributes do not work with `lwc:spread`

Open Mr-VincentW opened this issue 9 months ago • 2 comments

Is your feature request related to a problem? Please describe. According to the LWC ARIA Reflection documentation, non-standard ARIA attributes are supported in LWC. This allows attributes like <a-comp aria-labelledby="a-label-id"></a-comp> to work as expected.

However, this is not the case when using lwc:spread, where non-standard aira attributes cause an "Unknown public property" error and are not applied.

i.e., this does not work:

  • in HTML: <a-comp lwc:spread={props}></a-comp>
  • in JS: props = { ariaLabelledBy: 'a-label-id' };

Describe the solution you'd like Ensure that lwc:spread supports non-standard ARIA attributes so that the behavior aligns with manually adding them one by one.

Additional context The issue occurs because non-standard ARIA attributes do not exist in the HTML element's property chain, leading to a validation failure at: https://github.com/salesforce/lwc/blob/62feccae9ae68baf2fb8a04c629550d99e1af6de/packages/%40lwc/engine-core/src/framework/modules/props.ts#L62

These tickets might be relevant:

  • https://github.com/salesforce/lwc/issues/4545
  • https://github.com/salesforce/lwc/issues/4425

Mr-VincentW avatar Feb 09 '25 01:02 Mr-VincentW

Could you provide a playground link to reproduce the error? I've tried this and it seems to be rendering the attribute as expected.

Screenshot of app element from playground in dev tools elements panel

wjhsf avatar Feb 11 '25 16:02 wjhsf

Hi,

Thanks for getting back to me.

Since this validation applies to the element where the attributes are set, the issue occurs only with native HTML elements, where non-standard ARIA attributes are not reflected.

In your test case, moving lwc:spread={props} to another native HTML element reproduces the issue. For example:

<template>
    <h1 id="h1">Used as ARIA label</h1>
    <section label="Labeled by heading" lwc:spread={props}>Section Content</section>
</template>

Cheers.

Mr-VincentW avatar Feb 11 '25 18:02 Mr-VincentW