Skip to content

Commit 9c7a56b

Browse files
committed
fix: run exec only when relevant
1 parent 553a50e commit 9c7a56b

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

dist/autofill-debug.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/autofill.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Form/Form.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -527,14 +527,11 @@ class Form {
527527
/**
528528
* Executes a function on input elements. Can be limited to certain element types
529529
* @param {(input: HTMLInputElement|HTMLSelectElement) => void} fn
530-
* @param {'all' | SupportedMainTypes | SupportedMainTypes[]} inputType
530+
* @param {'all' | SupportedMainTypes} inputType
531531
* @param {boolean} shouldCheckForDecorate
532532
*/
533533
execOnInputs(fn, inputType = 'all', shouldCheckForDecorate = true) {
534-
// FIXME: This is a hack to support multiple input types, but I think we can work with just an array
535-
// Doing this as a quick hack to avoid changing all calling signatures at once.
536-
const inputTypes = Array.isArray(inputType) ? inputType : [inputType];
537-
const inputs = inputTypes.flatMap((inputType) => [...this.inputs[inputType]]);
534+
const inputs = [...this.inputs[inputType]];
538535
for (const input of inputs) {
539536
let canExecute = true;
540537
// sometimes we want to execute even if we didn't decorate
@@ -982,14 +979,15 @@ class Form {
982979
const elVCenter = y + height / 2;
983980
// This checks that the form is not covered by anything else
984981
const topMostElementFromPoint = document.elementFromPoint(elHCenter, elVCenter);
982+
const dataTypeToExec = this.isCCForm ? 'creditCards' : this.isLogin ? 'credentials' : null;
985983
if (this.form.contains(topMostElementFromPoint)) {
986-
this.execOnInputs(
984+
dataTypeToExec && this.execOnInputs(
987985
(input) => {
988986
if (isPotentiallyViewable(input)) {
989987
this.touched.add(input);
990988
}
991989
},
992-
['credentials', 'creditCards'],
990+
dataTypeToExec,
993991
);
994992
this.device.attachTooltip({
995993
form: this,

0 commit comments

Comments
 (0)