diff --git a/dist/autofill-debug.js b/dist/autofill-debug.js index 4d5258790..aa39663a1 100644 --- a/dist/autofill-debug.js +++ b/dist/autofill-debug.js @@ -11194,7 +11194,8 @@ class FormAnalyzer { const isCustomWebElementLink = customElements?.get(tagName) != null && /-link$/.test(tagName) && (0, _autofillUtils.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; + const isElementLink = el instanceof HTMLAnchorElement && el.href && el.getAttribute('href') !== '#' || (el.getAttribute('role') || '').toUpperCase() === 'LINK' || el.matches('button[class*=secondary]'); + return isCustomWebElementLink || isElementLink; } evaluateElement(el) { const string = (0, _autofillUtils.getTextShallow)(el); @@ -11216,7 +11217,7 @@ class FormAnalyzer { if (likelyASubmit) { this.form.querySelectorAll('input[type=submit], button[type=submit]').forEach(submit => { // If there is another element marked as submit and this is not, flip back to false - if (el.type !== 'submit' && el !== submit) { + if (el.getAttribute('type') !== 'submit' && el !== submit) { likelyASubmit = false; } }); diff --git a/dist/autofill.js b/dist/autofill.js index 69768221d..03be6f2b7 100644 --- a/dist/autofill.js +++ b/dist/autofill.js @@ -6831,7 +6831,8 @@ class FormAnalyzer { const isCustomWebElementLink = customElements?.get(tagName) != null && /-link$/.test(tagName) && (0, _autofillUtils.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; + const isElementLink = el instanceof HTMLAnchorElement && el.href && el.getAttribute('href') !== '#' || (el.getAttribute('role') || '').toUpperCase() === 'LINK' || el.matches('button[class*=secondary]'); + return isCustomWebElementLink || isElementLink; } evaluateElement(el) { const string = (0, _autofillUtils.getTextShallow)(el); @@ -6853,7 +6854,7 @@ class FormAnalyzer { if (likelyASubmit) { this.form.querySelectorAll('input[type=submit], button[type=submit]').forEach(submit => { // If there is another element marked as submit and this is not, flip back to false - if (el.type !== 'submit' && el !== submit) { + if (el.getAttribute('type') !== 'submit' && el !== submit) { likelyASubmit = false; } }); diff --git a/src/Form/FormAnalyzer.js b/src/Form/FormAnalyzer.js index 7f1acebe6..77647b70d 100644 --- a/src/Form/FormAnalyzer.js +++ b/src/Form/FormAnalyzer.js @@ -243,12 +243,12 @@ class FormAnalyzer { 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 ( + const isElementLink = (el instanceof HTMLAnchorElement && el.href && el.getAttribute('href') !== '#') || (el.getAttribute('role') || '').toUpperCase() === 'LINK' || - el.matches('button[class*=secondary]') || - isCustomWebElementLink - ); + el.matches('button[class*=secondary]'); + + return isCustomWebElementLink || isElementLink; } evaluateElement(el) { @@ -272,7 +272,7 @@ class FormAnalyzer { if (likelyASubmit) { this.form.querySelectorAll('input[type=submit], button[type=submit]').forEach((submit) => { // If there is another element marked as submit and this is not, flip back to false - if (el.type !== 'submit' && el !== submit) { + if (el.getAttribute('type') !== 'submit' && el !== submit) { likelyASubmit = false; } }); diff --git a/swift-package/Resources/assets/autofill-debug.js b/swift-package/Resources/assets/autofill-debug.js index 4d5258790..aa39663a1 100644 --- a/swift-package/Resources/assets/autofill-debug.js +++ b/swift-package/Resources/assets/autofill-debug.js @@ -11194,7 +11194,8 @@ class FormAnalyzer { const isCustomWebElementLink = customElements?.get(tagName) != null && /-link$/.test(tagName) && (0, _autofillUtils.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; + const isElementLink = el instanceof HTMLAnchorElement && el.href && el.getAttribute('href') !== '#' || (el.getAttribute('role') || '').toUpperCase() === 'LINK' || el.matches('button[class*=secondary]'); + return isCustomWebElementLink || isElementLink; } evaluateElement(el) { const string = (0, _autofillUtils.getTextShallow)(el); @@ -11216,7 +11217,7 @@ class FormAnalyzer { if (likelyASubmit) { this.form.querySelectorAll('input[type=submit], button[type=submit]').forEach(submit => { // If there is another element marked as submit and this is not, flip back to false - if (el.type !== 'submit' && el !== submit) { + if (el.getAttribute('type') !== 'submit' && el !== submit) { likelyASubmit = false; } }); diff --git a/swift-package/Resources/assets/autofill.js b/swift-package/Resources/assets/autofill.js index 69768221d..03be6f2b7 100644 --- a/swift-package/Resources/assets/autofill.js +++ b/swift-package/Resources/assets/autofill.js @@ -6831,7 +6831,8 @@ class FormAnalyzer { const isCustomWebElementLink = customElements?.get(tagName) != null && /-link$/.test(tagName) && (0, _autofillUtils.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; + const isElementLink = el instanceof HTMLAnchorElement && el.href && el.getAttribute('href') !== '#' || (el.getAttribute('role') || '').toUpperCase() === 'LINK' || el.matches('button[class*=secondary]'); + return isCustomWebElementLink || isElementLink; } evaluateElement(el) { const string = (0, _autofillUtils.getTextShallow)(el); @@ -6853,7 +6854,7 @@ class FormAnalyzer { if (likelyASubmit) { this.form.querySelectorAll('input[type=submit], button[type=submit]').forEach(submit => { // If there is another element marked as submit and this is not, flip back to false - if (el.type !== 'submit' && el !== submit) { + if (el.getAttribute('type') !== 'submit' && el !== submit) { likelyASubmit = false; } }); diff --git a/test-forms/index.json b/test-forms/index.json index 33b89c3b8..cbc1de347 100644 --- a/test-forms/index.json +++ b/test-forms/index.json @@ -546,6 +546,6 @@ { "html": "single-select-form.html" }, { "html": "camelcamelcamel_login.html" }, { "html": "accounts_oneplus_login.html"}, - { "html": "google_password_manager_search.html"} - + { "html": "google_password_manager_search.html"}, + { "html": "paperlesspost_login.html"} ] diff --git a/test-forms/paperlesspost_login.html b/test-forms/paperlesspost_login.html new file mode 100644 index 000000000..75e834a5d --- /dev/null +++ b/test-forms/paperlesspost_login.html @@ -0,0 +1,36 @@ +
\ No newline at end of file