Giter VIP home page Giter VIP logo

Comments (4)

joe-watkins avatar joe-watkins commented on July 27, 2024

.. or maybe even consider having JavaScript add a class focus-ring-polyfill that you can descend from:

.focus-ring-polyfill :focus:not(.focus-ring) { outline: none; }

With something like that JavaScript could fail or have an error and default focus states would be intact. See #8

from focus-visible.

robdodson avatar robdodson commented on July 27, 2024

Adding a class to the body works, but I'm concerned about causing really large style recalcs on older browsers.

Note: It used to be the case that if you changed a class on -- say -- the body element, that all the children in the page would need to have their computed styles recalculated. Thankfully that is no longer the case; some browsers instead maintain a small collection of rules unique to each element that, if changed, cause the element’s styles to be recalculated. That means that an element may or may not need to be recalculated depending on where it is in the tree, and what specifically got changed.
https://developers.google.com/web/fundamentals/performance/rendering/reduce-the-scope-and-complexity-of-style-calculations#reduce_the_number_of_elements_being_styled

I did a test in Chrome and things are fine, we only recalc 1 element if it's a mouse click, or 2 elements if we're tabbing and the focus ring is moving. But I'm less optimistic about older versions of IE. @paullewis were you referring to specific browsers in that comment? I'd love to know the versions if so.

from focus-visible.

robdodson avatar robdodson commented on July 27, 2024

Another option is the polyfill could inject the styles itself. That way it only does it if JS is working. I'm not in love with the idea of something injecting CSS because I prefer having total control over that, but it might be a decent compromise in this case. Or we could even make it configurable.

from focus-visible.

robdodson avatar robdodson commented on July 27, 2024

We're going with the class on body approach as discussed in #8

I'm going to close this issue so we can track the work in #8.

from focus-visible.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.