Bug 1395173 - Part 1. Cache computed values in form handler instance instead of prototype. r=lchang
MozReview-Commit-ID: Dwz6EmJ4VmN
--- a/browser/extensions/formautofill/FormAutofillHandler.jsm
+++ b/browser/extensions/formautofill/FormAutofillHandler.jsm
@@ -49,16 +49,22 @@ function FormAutofillHandler(form) {
* Similar to the `fieldDetails` above but contains credit card fields only.
*/
fieldDetails: [],
/**
* String of the filled creditCard's guid.
*/
filledRecordGUID: null,
};
+
+ this._cacheValue = {
+ allFieldNames: null,
+ oneLineStreetAddress: null,
+ matchingSelectOption: null,
+ };
}
FormAutofillHandler.prototype = {
/**
* DOM Form element to which this object is attached.
*/
form: null,
@@ -164,22 +170,16 @@ FormAutofillHandler.prototype = {
return this.address.fieldDetails;
}
if (FormAutofillUtils.isCreditCardField(fieldDetail.fieldName)) {
return this.creditCard.fieldDetails;
}
return [];
},
- _cacheValue: {
- allFieldNames: null,
- oneLineStreetAddress: null,
- matchingSelectOption: null,
- },
-
get allFieldNames() {
if (!this._cacheValue.allFieldNames) {
this._cacheValue.allFieldNames = this.fieldDetails.map(record => record.fieldName);
}
return this._cacheValue.allFieldNames;
},
_getOneLineStreetAddress(address) {