Description
openedon Sep 3, 2022
🙋 Feature Request
Add the ability to proxy attributes to an internal node and never reflect them on the DOM element.
This is useful for aria-*
attributes or role
which makes more sense to set on an internal element within a host's shadow rather than the host itself.
🤔 Expected Behavior
@attr
mode can be leveraged and allow additional strategy like "never"
(or "delegate"
or "proxy"
).
😯 Current Behavior
@attr
mode allow only the following "reflect" | "boolean" | "fromView"
This might be opinionated, but our code style approach is to try and avoid DOM elements from mutating at run-time and keep a consistent result to what authors write and expect, making custom elements behave like black-box services.
in the following FAST menu item, role
assigned with a default value will mutate and apply a role on the host when authors aren't setting it.
fast/packages/web-components/fast-foundation/src/menu-item/menu-item.ts
Lines 115 to 116 in 1d230aa
Now this might conflict with the fact that attribute set by author would be removed at run-time when @attr is set to 'never | proxy | delegate'. but it's mandatory to avoid screenreader conflicts.
💻 Examples
Material team has written a decorator dedicated for this type of behavior and it is explained very well here
A property decorator that helps proxy an aria attribute to an internal node.
This decorator is only intended for use with ARIAMixin properties,
such asariaLabel
, to help with screen readers.This decorator will remove the host
aria-*
attribute at runtime and add it
to adata-aria-*
attribute to avoid screenreader conflicts between the
host and internal node.
@ariaProperty
decorated properties should sync with LitElement to the
data-aria-*
attribute, not the nativearia-*
attribute.
Metadata
Assignees
Type
Projects
Status
Triage