Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Credentials] Autofill when elements are in shadow #592

Merged
merged 22 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: fix types
  • Loading branch information
dbajpeyi committed Jul 16, 2024
commit 6c543b614bcc917ce38bb52e66084bd8d27d3874
10 changes: 3 additions & 7 deletions dist/autofill-debug.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions dist/autofill.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/Scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ class DefaultScanner {
inputs.forEach((input) => this.addInput(input))
if (context instanceof HTMLFormElement && this.forms.get(context)?.hasShadowInput) {
const selector = this.matching.cssSelector('formInputsSelectorWithoutSelect')
const shadowElements = findEnclosedElements(context, selector)
shadowElements.forEach((input) => {
findEnclosedElements(context, selector).forEach((input) => {
if (input instanceof HTMLInputElement) {
this.addInput(input, context)
}
Expand Down
6 changes: 2 additions & 4 deletions src/autofill-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,13 +570,12 @@ function getActiveElement (root = document) {
* Takes a form element, creates a treewalker and finds all shadow elements that match the selector
* @param {HTMLElement|HTMLFormElement} root
* @param {string} selector
* @returns {HTMLElement[]}
* @returns {Element[]}
*/
function findEnclosedElements (root, selector) {
// Check if there are any normal elements that match the selector
const elements = root.querySelectorAll(selector)
const elements = [...root.querySelectorAll(selector)]
if (elements.length > 0) {
/** @ts-ignore */
return elements
}

Expand All @@ -592,7 +591,6 @@ function findEnclosedElements (root, selector) {
node = walker.nextNode()
}

/** @ts-ignore */
return shadowElements
}

Expand Down
10 changes: 3 additions & 7 deletions swift-package/Resources/assets/autofill-debug.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions swift-package/Resources/assets/autofill.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading