-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Support a template-enabled [submitting] element #9442
Conversation
extensions/amp-form/0.1/amp-form.js
Outdated
} else { | ||
xhrUrl = this.xhrAction_; | ||
body = new FormData(this.form_); | ||
for (const key in opt_extraValues) { | ||
body.append(key, opt_extraValues[key]); | ||
} | ||
values = {}; | ||
const entries = body.entries(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iterators are not supported everywhere.
@@ -440,17 +440,20 @@ export class AmpForm { | |||
*/ | |||
doXhr_(opt_extraValues) { | |||
const isHeadOrGet = this.method_ == 'GET' || this.method_ == 'HEAD'; | |||
const values = this.getFormAsObject_(opt_extraValues); | |||
this.renderTemplate_(values); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will render all templates which causes unnecessary rendering of success/failure templates as well. would be nice if renderTemplate
could take the type of target template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should just render whatever template matches the current form state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Justin's assessment is correct, it only render's the current state's template. In this case it's the FormState_.SUBMITTING
state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great
@@ -564,6 +564,7 @@ amp-iframe iframe { | |||
/** | |||
* Forms error/success messaging containers should be hidden at first. | |||
*/ | |||
form [submitting], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validator file needs to be changed to support a similar rule to spec_name: "FORM > DIV [submit-success]"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is now live in prod. |
Fixes #8601