GithubHelp home page GithubHelp logo

Comments (7)

valdrinkoshi avatar valdrinkoshi commented on July 18, 2024 1

Tested in STP and Chrome and it works 🎉 http://jsbin.com/lizipoq/2/edit?html,output
Notice how focus is returned to the right place if any element within a shadow root steals focus programmatically through focus()

from inert.

robdodson avatar robdodson commented on July 18, 2024

sounds like a great idea to me. @valdrinkoshi do you have any interest in putting together a PR for it?

from inert.

valdrinkoshi avatar valdrinkoshi commented on July 18, 2024

sure i can give it a shot.
Tangential note: I'm wondering if we should drop completely the support of WebComponents v0...

from inert.

robdodson avatar robdodson commented on July 18, 2024

hm... I think I'm cool with dropping v0. @alice wdyt?

from inert.

alice avatar alice commented on July 18, 2024

from inert.

robdodson avatar robdodson commented on July 18, 2024

ehhhh.... it's in Chrome and will be for quite some time...

from inert.

valdrinkoshi avatar valdrinkoshi commented on July 18, 2024

Yeah, and that makes things harder, as we can't know if a shadowRoot was generated via Element.createShadowRoot() (v0) or Element.attachShadow() (v1) http://jsbin.com/tenobar/1/edit?html,output
We could assume that if the shadowRoot has a <content> element that's a v0 shadowRoot, but some shadowRoots don't have distribution elements at all.
Also, we can't "cleanly" recognize if we are in a polyfilled ShadowDOM (e.g. we would have to check for window.ShadyDOM to support the shadydom polyfill, or other checks for other polyfills).

Apart of this problem, even if we focus only on shadowDOM v1 in chrome, we have the following challenges:

  1. we still have to override focus() for elements inside a shadowRoot in order to avoid scrolling from happening (e.g. see this example http://jsbin.com/hohegoj/4/edit?html,output) - this means we don't save much because we have to traverse the tree. We can avoid this by overriding the HTMLElement.prototype.focus where we could check if the node is inert or inside an inert parent.
  2. what to do if a rootElement doesn't have a shadowRoot? If we attachShadow, we prevent other people from doing so.

Will try to deliver something on the basis that ShadowDOM v1 is natively supported, and see how good/bad it is compared to what we have currently 👌

from inert.

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.