Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(inputs): refactor form-elements gatherer #13662

Merged
merged 3 commits into from
Feb 14, 2022
Merged

Conversation

connorjclark
Copy link
Collaborator

Refactors + renames the form-elements gatherer.

Instead of structuring the input elements inside form objects, place each input/label/form object into top-level properties and use indices to connect an input element with a form/labels.

It is still possible to query the artifact for "formless inputs" or "inputless labels" (if we ever wish to).

@connorjclark connorjclark requested a review from a team as a code owner February 14, 2022 21:02
@connorjclark connorjclark requested review from adamraine and removed request for a team February 14, 2022 21:02
@@ -72,8 +72,7 @@ const smokeTests = [
errorsExpiredSsl,
errorsIframeExpiredSsl,
errorsInfiniteLoop,
// TODO: restore when --enable-features=AutofillShowTypePredictions is not needed.
// formsAutoComplete,
formsAutoComplete,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've enabled the smoke test, but commented out the stuff that rely on the predictions being available.

const failingFormsData = [];
const warnings = [];
let foundPrediction = false;
for (const form of forms) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just whitespace changes, I didn't modify the logic.

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice refactor. feels better

autocomplete: {
property: 'cc-exp-month',
attribute: 'cc-exp-month',
prediction: null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all predictions are now null. lets add a comment.. somewhere in this file... to clarify that they'd be populated if the flag were used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a comment below that mentions the flag

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i saw that. but it's for the section you commented out. :)
i don't think the comment on line 467 is gonna help give context to whats happening on line 70..
so i was suggesting an additional comment.

Comment on lines 60 to 65
parentFormIndex: parentFormEl ?
[...formElToArtifact.keys()].indexOf(parentFormEl) :
undefined,
labelIndicies: [...inputEl.labels || []].map((labelEl) => {
return [...labelElToArtifact.keys()].indexOf(labelEl);
}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: For readability, can you compute these on their own lines

@@ -0,0 +1,111 @@
/**
* @license Copyright 2020 The Lighthouse Authors. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @license Copyright 2020 The Lighthouse Authors. All Rights Reserved.
* @license Copyright 2022 The Lighthouse Authors. All Rights Reserved.

Copy link
Collaborator Author

@connorjclark connorjclark Feb 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a file rename. kinda.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are enough changes to consider this a new file imo, but I'll leave it up to you

interface FormElement {
id: string;
name: string;
autocomplete: string;
node: NodeDetails | null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a situation where this is null?

@connorjclark connorjclark merged commit d55bea0 into master Feb 14, 2022
@connorjclark connorjclark deleted the inputs-artifact branch February 14, 2022 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants