-
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
Implement A2A support #13300
Implement A2A support #13300
Conversation
aadd679
to
483cea1
Compare
4f93c42
to
9dade4d
Compare
* Lazy-generated list of A2A-enabled navigation features. | ||
* @private {?Array<string>} | ||
*/ | ||
this.a2aFeatures_ = null; |
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.
I thought we wanted to avoid calling it a2a?
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.
Externally, yes. Internally I think it's fine.
} | ||
|
||
// Otherwise, perform normal behavior of navigating the top frame. | ||
win.top.location.href = 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.
Why doesn't this handle custom protocols, too?
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.
I considered this too. amp-form
by spec only allows https protocol, but we maybe should add this to AMP.navigateTo
. Leaving this and the other <a>
behaviors (getExtraParamsUrl
, URL expansion, etc.) for future work.
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.
Please make an issue for it.
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.
src/service/document-click.js
Outdated
const meta = this.rootNode_.querySelector( | ||
'meta[name="amp-to-amp-navigation"]'); | ||
this.a2aFeatures_ = (meta && meta.hasAttribute('content')) | ||
? meta.getAttribute('content').split(',').map(s => s.trim()) |
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.
We can remove the #map
by splitting whitespace: content.trim().split(/\s*,\s*/)
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.
I'd prefer to leave as is for readability.
src/service/document-click.js
Outdated
'meta[name="amp-to-amp-navigation"]'); | ||
this.a2aFeatures_ = (meta && meta.hasAttribute('content')) | ||
? meta.getAttribute('content').split(',').map(s => s.trim()) | ||
: []; |
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.
Nit: split this into if
/else
.
src/service/document-click.js
Outdated
? meta.getAttribute('content').split(',').map(s => s.trim()) | ||
: []; | ||
} | ||
if (this.a2aFeatures_.indexOf(opt_requestedBy) >= 0) { |
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.
Array#includes
is polyfilled.
src/service/document-click.js
Outdated
*/ | ||
handleA2AClick_(e, target, location) { | ||
const relations = (target.hasAttribute('rel')) | ||
? target.getAttribute('rel').split(' ').map(s => s.trim()) |
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.
Ditto splitting whitespace.
src/service/document-click.js
Outdated
const relations = (target.hasAttribute('rel')) | ||
? target.getAttribute('rel').split(' ').map(s => s.trim()) | ||
: []; | ||
if (relations.indexOf('amphtml') < 0) { |
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.
Ditto #includes
.
d97ce0a
to
393a959
Compare
Tested locally with |
* squash and include a2a changes * fix lint * fix other tests * unit tests * fix lint * update amp-form tests * justin's comments
* squash and include a2a changes * fix lint * fix other tests * unit tests * fix lint * update amp-form tests * justin's comments
* squash and include a2a changes * fix lint * fix other tests * unit tests * fix lint * update amp-form tests * justin's comments
Closes #12496 and fixes #13056.
a2a
viewer message and capabilityClickHandler
service (will be renamed toNavigation
after)<a rel=amphtml>
for links and<meta name="amp-to-amp-navigation" content="AMP.navigateTo, AMP-Redirect-To">
for other navigational featuresTODO: Follow up with documentation and validator changes.