philc / philc/vimium

Find Hints Within Shadow Roots

Open
#3,376 0 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
27k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Vimium currently cannot identify buttons, links, etc. when they are buried within the Shadow DOM (example). A minor modification to make the look-up method recursive could resolve this. See the following for a reduction of the issue: https://jsfiddle.net/gh5m94p7/4/.

And example look-up approach

// Pass in the root element, and whether or not to pierce Shadow DOMs
const getAll = ( root, includeShadows ) => {
  // Document Fragments support querySelectorAll
  let items = Array.from( root.querySelectorAll( '*' ) )
  items.forEach( item => {
  	if ( item.shadowRoot )
        // Recursively call getAll to include shadow roots
    	items = items.concat( getAll( item.shadowRoot, true ) )
  })
  return items
}

Current lookup takes place here: https://github.com/philc/vimium/blob/881a6fdc3644f55fc02ad56454203f654cc76618/content_scripts/link_hints.coffee#L748

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at content_scripts/link_hints.coffee around line 748, where the current element lookup is implemented, and compare it with the reduced Shadow DOM example in the issue. Verify the lookup across nested shadow roots and confirm that buttons and links inside them become available to link hints.

Written by the indexing model from the issue text.

Assessment

Tech stack
coffeescript, javascript
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.