-
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
Allow XHR Submissions on forms #3483
Conversation
return; | ||
} | ||
if (this.xhrAction_) { | ||
this.xhr_.fetchJson(this.xhrAction_, { |
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.
Probably want to turn on credentials and requireAmpResponseSourceOrigin
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.
@cramforce @dvoytenko PTAL |
/** @const @private {?string} */ | ||
this.xhrAction_ = this.form_.getAttribute('action-xhr'); | ||
if (this.xhrAction_) { | ||
assertHttpsUrl(this.xhrAction_, this.form_, 'action-xhr'); |
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.
Before doing these checks, we need to resolve xhrAction_
to the full URL. Otherwise we can't test if it starts with https://...
is not valid.
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.
Also, we need to file against the cache/cdn:
- Resolve
form[action]
attribute to the absolute URL - Resolve
form[action-xhr]
attribute to the absolute URL.
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.
Filed.
LGTM with one fix requested. |
ITI: #3343
Writing some tests. Let me know if this looks good!