hasOwnProperty continue
This commit is contained in:
parent
79c2fdac48
commit
c6274dd1dc
|
@ -407,40 +407,42 @@ export default class AutofillService {
|
||||||
|
|
||||||
for (const f of pageDetails.fields) {
|
for (const f of pageDetails.fields) {
|
||||||
for (const attr of CardAttributes) {
|
for (const attr of CardAttributes) {
|
||||||
if (f.hasOwnProperty(attr) && f[attr]) {
|
if (!f.hasOwnProperty(attr) || !f[attr]) {
|
||||||
// ref https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill
|
continue;
|
||||||
// ref https://developers.google.com/web/fundamentals/design-and-ux/input/forms/
|
}
|
||||||
if (!fillFields.cardholderName && this.isFieldMatch(f[attr],
|
|
||||||
['cc-name', 'card-name', 'cardholder-name', 'cardholder', 'name'],
|
// ref https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill
|
||||||
['cc-name', 'card-name', 'cardholder-name', 'cardholder'])) {
|
// ref https://developers.google.com/web/fundamentals/design-and-ux/input/forms/
|
||||||
fillFields.cardholderName = f;
|
if (!fillFields.cardholderName && this.isFieldMatch(f[attr],
|
||||||
} else if (!fillFields.number && this.isFieldMatch(f[attr],
|
['cc-name', 'card-name', 'cardholder-name', 'cardholder', 'name'],
|
||||||
['cc-number', 'cc-num', 'card-number', 'card-num', 'number'],
|
['cc-name', 'card-name', 'cardholder-name', 'cardholder'])) {
|
||||||
['cc-number', 'cc-num', 'card-number', 'card-num'])) {
|
fillFields.cardholderName = f;
|
||||||
fillFields.number = f;
|
} else if (!fillFields.number && this.isFieldMatch(f[attr],
|
||||||
} else if (!fillFields.exp && this.isFieldMatch(f[attr],
|
['cc-number', 'cc-num', 'card-number', 'card-num', 'number'],
|
||||||
['cc-exp', 'card-exp', 'cc-expiration', 'card-expiration', 'cc-ex', 'card-ex'],
|
['cc-number', 'cc-num', 'card-number', 'card-num'])) {
|
||||||
[])) {
|
fillFields.number = f;
|
||||||
fillFields.exp = f;
|
} else if (!fillFields.exp && this.isFieldMatch(f[attr],
|
||||||
} else if (!fillFields.expMonth && this.isFieldMatch(f[attr],
|
['cc-exp', 'card-exp', 'cc-expiration', 'card-expiration', 'cc-ex', 'card-ex'],
|
||||||
['exp-month', 'cc-exp-month', 'cc-month', 'card-month', 'cc-mo', 'card-mo', 'exp-mo',
|
[])) {
|
||||||
'card-exp-mo', 'cc-exp-mo', 'card-expiration-month', 'expiration-month',
|
fillFields.exp = f;
|
||||||
'cc-mm', 'card-mm', 'card-exp-mm', 'cc-exp-mm', 'exp-mm'])) {
|
} else if (!fillFields.expMonth && this.isFieldMatch(f[attr],
|
||||||
fillFields.expMonth = f;
|
['exp-month', 'cc-exp-month', 'cc-month', 'card-month', 'cc-mo', 'card-mo', 'exp-mo',
|
||||||
} else if (!fillFields.expYear && this.isFieldMatch(f[attr],
|
'card-exp-mo', 'cc-exp-mo', 'card-expiration-month', 'expiration-month',
|
||||||
['exp-year', 'cc-exp-year', 'cc-year', 'card-year', 'cc-yr', 'card-yr', 'exp-yr',
|
'cc-mm', 'card-mm', 'card-exp-mm', 'cc-exp-mm', 'exp-mm'])) {
|
||||||
'card-exp-yr', 'cc-exp-yr', 'card-expiration-year', 'expiration-year',
|
fillFields.expMonth = f;
|
||||||
'cc-yy', 'card-yy', 'card-exp-yy', 'cc-exp-yy', 'exp-yy',
|
} else if (!fillFields.expYear && this.isFieldMatch(f[attr],
|
||||||
'cc-yyyy', 'card-yyyy', 'card-exp-yyyy', 'cc-exp-yyyy'])) {
|
['exp-year', 'cc-exp-year', 'cc-year', 'card-year', 'cc-yr', 'card-yr', 'exp-yr',
|
||||||
fillFields.expYear = f;
|
'card-exp-yr', 'cc-exp-yr', 'card-expiration-year', 'expiration-year',
|
||||||
} else if (!fillFields.code && this.isFieldMatch(f[attr],
|
'cc-yy', 'card-yy', 'card-exp-yy', 'cc-exp-yy', 'exp-yy',
|
||||||
['cvv', 'cvc', 'cvv2', 'cc-csc', 'cc-cvv', 'card-csc', 'card-cvv', 'cvd',
|
'cc-yyyy', 'card-yyyy', 'card-exp-yyyy', 'cc-exp-yyyy'])) {
|
||||||
'cid', 'cvc2', 'cnv', 'cvn2', 'cc-code', 'card-code'])) {
|
fillFields.expYear = f;
|
||||||
fillFields.code = f;
|
} else if (!fillFields.code && this.isFieldMatch(f[attr],
|
||||||
} else if (!fillFields.brand && this.isFieldMatch(f[attr],
|
['cvv', 'cvc', 'cvv2', 'cc-csc', 'cc-cvv', 'card-csc', 'card-cvv', 'cvd',
|
||||||
['cc-type', 'card-type', 'card-brand', 'cc-brand'])) {
|
'cid', 'cvc2', 'cnv', 'cvn2', 'cc-code', 'card-code'])) {
|
||||||
fillFields.brand = f;
|
fillFields.code = f;
|
||||||
}
|
} else if (!fillFields.brand && this.isFieldMatch(f[attr],
|
||||||
|
['cc-type', 'card-type', 'card-brand', 'cc-brand'])) {
|
||||||
|
fillFields.brand = f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -479,64 +481,66 @@ export default class AutofillService {
|
||||||
|
|
||||||
for (const f of pageDetails.fields) {
|
for (const f of pageDetails.fields) {
|
||||||
for (const attr of IdentityAttributes) {
|
for (const attr of IdentityAttributes) {
|
||||||
if (f.hasOwnProperty(attr) && f[attr]) {
|
if (!f.hasOwnProperty(attr) || !f[attr]) {
|
||||||
// ref https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill
|
continue;
|
||||||
// ref https://developers.google.com/web/fundamentals/design-and-ux/input/forms/
|
}
|
||||||
if (!fillFields.name && this.isFieldMatch(f[attr],
|
|
||||||
['name', 'full-name', 'your-name'], ['full-name', 'your-name'])) {
|
// ref https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill
|
||||||
fillFields.name = f;
|
// ref https://developers.google.com/web/fundamentals/design-and-ux/input/forms/
|
||||||
} else if (!fillFields.firstName && this.isFieldMatch(f[attr],
|
if (!fillFields.name && this.isFieldMatch(f[attr],
|
||||||
['f-name', 'first-name', 'given-name', 'first-n'])) {
|
['name', 'full-name', 'your-name'], ['full-name', 'your-name'])) {
|
||||||
fillFields.firstName = f;
|
fillFields.name = f;
|
||||||
} else if (!fillFields.middleName && this.isFieldMatch(f[attr],
|
} else if (!fillFields.firstName && this.isFieldMatch(f[attr],
|
||||||
['m-name', 'middle-name', 'additional-name', 'middle-initial', 'middle-n', 'middle-i'])) {
|
['f-name', 'first-name', 'given-name', 'first-n'])) {
|
||||||
fillFields.middleName = f;
|
fillFields.firstName = f;
|
||||||
} else if (!fillFields.lastName && this.isFieldMatch(f[attr],
|
} else if (!fillFields.middleName && this.isFieldMatch(f[attr],
|
||||||
['l-name', 'last-name', 's-name', 'surname', 'family-name', 'family-n', 'last-n'])) {
|
['m-name', 'middle-name', 'additional-name', 'middle-initial', 'middle-n', 'middle-i'])) {
|
||||||
fillFields.lastName = f;
|
fillFields.middleName = f;
|
||||||
} else if (!fillFields.title && this.isFieldMatch(f[attr],
|
} else if (!fillFields.lastName && this.isFieldMatch(f[attr],
|
||||||
['honorific-prefix', 'prefix', 'title'])) {
|
['l-name', 'last-name', 's-name', 'surname', 'family-name', 'family-n', 'last-n'])) {
|
||||||
fillFields.title = f;
|
fillFields.lastName = f;
|
||||||
} else if (!fillFields.email && this.isFieldMatch(f[attr],
|
} else if (!fillFields.title && this.isFieldMatch(f[attr],
|
||||||
['e-mail', 'email-address'])) {
|
['honorific-prefix', 'prefix', 'title'])) {
|
||||||
fillFields.email = f;
|
fillFields.title = f;
|
||||||
} else if (!fillFields.address && this.isFieldMatch(f[attr],
|
} else if (!fillFields.email && this.isFieldMatch(f[attr],
|
||||||
['address', 'street-address'], [])) {
|
['e-mail', 'email-address'])) {
|
||||||
fillFields.address = f;
|
fillFields.email = f;
|
||||||
} else if (!fillFields.address1 && this.isFieldMatch(f[attr],
|
} else if (!fillFields.address && this.isFieldMatch(f[attr],
|
||||||
['address-1', 'address-line-1'])) {
|
['address', 'street-address'], [])) {
|
||||||
fillFields.address1 = f;
|
fillFields.address = f;
|
||||||
} else if (!fillFields.address2 && this.isFieldMatch(f[attr],
|
} else if (!fillFields.address1 && this.isFieldMatch(f[attr],
|
||||||
['address-2', 'address-line-2'])) {
|
['address-1', 'address-line-1'])) {
|
||||||
fillFields.address2 = f;
|
fillFields.address1 = f;
|
||||||
} else if (!fillFields.address3 && this.isFieldMatch(f[attr],
|
} else if (!fillFields.address2 && this.isFieldMatch(f[attr],
|
||||||
['address-3', 'address-line-3'])) {
|
['address-2', 'address-line-2'])) {
|
||||||
fillFields.address3 = f;
|
fillFields.address2 = f;
|
||||||
} else if (!fillFields.city && this.isFieldMatch(f[attr],
|
} else if (!fillFields.address3 && this.isFieldMatch(f[attr],
|
||||||
['city', 'town', 'address-level-2', 'address-city', 'address-town'])) {
|
['address-3', 'address-line-3'])) {
|
||||||
fillFields.city = f;
|
fillFields.address3 = f;
|
||||||
} else if (!fillFields.state && this.isFieldMatch(f[attr],
|
} else if (!fillFields.city && this.isFieldMatch(f[attr],
|
||||||
['state', 'province', 'provence', 'address-level-1', 'address-state',
|
['city', 'town', 'address-level-2', 'address-city', 'address-town'])) {
|
||||||
'address-province'])) {
|
fillFields.city = f;
|
||||||
fillFields.state = f;
|
} else if (!fillFields.state && this.isFieldMatch(f[attr],
|
||||||
} else if (!fillFields.postalCode && this.isFieldMatch(f[attr],
|
['state', 'province', 'provence', 'address-level-1', 'address-state',
|
||||||
['postal', 'zip', 'zip2', 'zip-code', 'postal-code', 'address-zip', 'address-postal',
|
'address-province'])) {
|
||||||
'address-code', 'address-postal-code', 'address-zip-code'])) {
|
fillFields.state = f;
|
||||||
fillFields.postalCode = f;
|
} else if (!fillFields.postalCode && this.isFieldMatch(f[attr],
|
||||||
} else if (!fillFields.country && this.isFieldMatch(f[attr],
|
['postal', 'zip', 'zip2', 'zip-code', 'postal-code', 'address-zip', 'address-postal',
|
||||||
['country', 'country-code', 'country-name', 'address-country', 'address-country-name',
|
'address-code', 'address-postal-code', 'address-zip-code'])) {
|
||||||
'address-country-code'])) {
|
fillFields.postalCode = f;
|
||||||
fillFields.country = f;
|
} else if (!fillFields.country && this.isFieldMatch(f[attr],
|
||||||
} else if (!fillFields.phone && this.isFieldMatch(f[attr],
|
['country', 'country-code', 'country-name', 'address-country', 'address-country-name',
|
||||||
['phone', 'mobile', 'mobile-phone', 'tel', 'telephone', 'phone-number'])) {
|
'address-country-code'])) {
|
||||||
fillFields.phone = f;
|
fillFields.country = f;
|
||||||
} else if (!fillFields.username && this.isFieldMatch(f[attr],
|
} else if (!fillFields.phone && this.isFieldMatch(f[attr],
|
||||||
['user-name', 'user-id', 'screen-name'])) {
|
['phone', 'mobile', 'mobile-phone', 'tel', 'telephone', 'phone-number'])) {
|
||||||
fillFields.username = f;
|
fillFields.phone = f;
|
||||||
} else if (!fillFields.company && this.isFieldMatch(f[attr],
|
} else if (!fillFields.username && this.isFieldMatch(f[attr],
|
||||||
['company', 'company-name', 'organization', 'organization-name'])) {
|
['user-name', 'user-id', 'screen-name'])) {
|
||||||
fillFields.company = f;
|
fillFields.username = f;
|
||||||
}
|
} else if (!fillFields.company && this.isFieldMatch(f[attr],
|
||||||
|
['company', 'company-name', 'organization', 'organization-name'])) {
|
||||||
|
fillFields.company = f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue