Skip to content

[focus-visible-plugin] .js-focus-visible breaks output when leveraged with shadow DOM #557

Closed
@Westbrook

Description

@Westbrook

What would you want to propose?

I'd like API to customize the application of .js-focus-visible in the focus-visible-plugin.

The recent upgrade of the focus-vidible-plugin to include .js-focus-visible creates selectors that do not exist when leveraged with CSS targeted for application to shadow DOM. Generally the shadow DOM implementation of the polyfill cannot rely on parent elements having .js-focus-visible and doesn't seem to apply .js-focus-visible to the focused element.

Suggested solution

I'm not sure if a legacy flag is correct, or if a scopedSelector flag would be better, but being able to do the following in some form:

require('postcss-focus-visible')({
    scopePolyfilledSelectors: false,
})

Additional context

Input:

:host(:focus-visible) {}

Output:

.js-focus-visible :host(.focus-visible),
:host(.focus-visible).js-focus-visible {}

:host(:focus-visible) {}

Expected:

:host(.focus-visible) {}

:host(:focus-visible) {}

Validations

  • Follow our Code of Conduct
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Would you like to open a PR for this feature?

  • I'm willing to open a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions