Skip to content

Commit beb2f9d

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

File tree

4 files changed

+54
-38
lines changed

4 files changed

+54
-38
lines changed

dist/autofill-debug.js

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

dist/autofill.js

Lines changed: 17 additions & 13 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: 8 additions & 10 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,15 +979,16 @@ 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 dataTypeForExec = this.isCCForm ? 'creditCards' : this.isLogin ? 'credentials' : null;
983+
985984
if (this.form.contains(topMostElementFromPoint)) {
986-
this.execOnInputs(
987-
(input) => {
985+
// Add inputs to the touched set only for the dataTypeForExec, which currentl
986+
dataTypeForExec &&
987+
this.execOnInputs((input) => {
988988
if (isPotentiallyViewable(input)) {
989989
this.touched.add(input);
990990
}
991-
},
992-
['credentials', 'creditCards'],
993-
);
991+
}, dataTypeForExec);
994992
this.device.attachTooltip({
995993
form: this,
996994
input,

src/Form/inputTypeConfig.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,21 @@ const inputTypeConfig = {
155155
getIconBase: (input, form) => {
156156
const { device } = form;
157157
const subtype = getInputSubtype(input);
158-
const isValidInputSubType = subtype === 'cardName' || subtype === 'cardNumber' || subtype === 'cardSecurityCode';
158+
const isValidInputSubType = subtype === 'cardNumber' || subtype === 'cardSecurityCode';
159+
159160
if (canBeInteractedWith(input) && device.globalConfig.isMobileApp && isValidInputSubType) return ddgPasswordIcons.ddgCcIconBase;
161+
162+
return '';
163+
},
164+
getIconFilled: (input, form) => {
165+
const { device } = form;
166+
const subtype = getInputSubtype(input);
167+
const isValidInputSubType = subtype === 'cardNumber' || subtype === 'cardSecurityCode';
168+
169+
if (device.globalConfig.isMobileApp && isValidInputSubType) return ddgPasswordIcons.ddgCcIconFilled;
170+
160171
return '';
161172
},
162-
getIconFilled: () => ddgPasswordIcons.ddgCcIconFilled,
163173
getIconAlternate: () => '',
164174
shouldDecorate: async (input, { device }) => {
165175
return canBeAutofilled(input, device);

0 commit comments

Comments
 (0)