Skip to content

Commit

Permalink
chore: PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dbajpeyi committed Nov 21, 2024
1 parent 7ba8e49 commit d053481
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 45 deletions.
19 changes: 11 additions & 8 deletions dist/autofill-debug.js

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

19 changes: 11 additions & 8 deletions dist/autofill.js

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

30 changes: 17 additions & 13 deletions src/Form/FormAnalyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,25 @@ class FormAnalyzer {
}

/**
* Checks if the element is present in the cusotm elements registry and ends with a '-link' suffix.
* If it does, it checks if it contains an anchor element inside.
* Function that checks if the element is an external link or a custom web element that
* encapsulates a link.
* @param {any} el
* @returns
* @returns {boolean}
*/
isCustomWebElementLink(el) {
isElementExternalLink(el) {
// Checks if the element is present in the cusotm elements registry and ends with a '-link' suffix.
// If it does, it checks if it contains an anchor element inside.
const tagName = el.nodeName.toLowerCase();
const isCustomElement = customElements != null && customElements.get(tagName) != null;
return isCustomElement && /-link$/.test(tagName) && findElementsInShadowTree(el, 'a').length > 0;
const isCustomWebElementLink =
customElements.get(tagName) != null && /-link$/.test(tagName) && findElementsInShadowTree(el, 'a').length > 0;

// if an external link matches one of the regexes, we assume the match is not pertinent to the current form
return (
(el instanceof HTMLAnchorElement && el.href && el.getAttribute('href') !== '#') ||
(el.getAttribute('role') || '').toUpperCase() === 'LINK' ||
el.matches('button[class*=secondary]') ||
isCustomWebElementLink
);
}

evaluateElement(el) {
Expand Down Expand Up @@ -270,13 +280,7 @@ class FormAnalyzer {
this.updateSignal({ string, strength, signalType: `button: ${string}`, shouldFlip });
return;
}
// if an external link matches one of the regexes, we assume the match is not pertinent to the current form
if (
(el instanceof HTMLAnchorElement && el.href && el.getAttribute('href') !== '#') ||
(el.getAttribute('role') || '').toUpperCase() === 'LINK' ||
el.matches('button[class*=secondary]') ||
this.isCustomWebElementLink(el)
) {
if (this.isElementExternalLink(el)) {
let shouldFlip = true;
let strength = 1;
// Don't flip forgotten password links
Expand Down
19 changes: 11 additions & 8 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.

19 changes: 11 additions & 8 deletions swift-package/Resources/assets/autofill.js

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

0 comments on commit d053481

Please sign in to comment.