✨ Amp Actions: AMP.goBack action should call history.back#26585
✨ Amp Actions: AMP.goBack action should call history.back#26585samouri merged 12 commits intoampproject:masterfrom
Conversation
4b95ad5 to
966135b
Compare
|
Not a huge fan of this name. Maybe we can parameterize |
I mentioned this on the issue as well. But I believe in the current world, we could just extend |
|
Does that mean:
|
From what I can see: a history stack modification with a user gesture is very unambiguous for within- and cross-doc navigation (i.e. history stack pop). I'd even constraint all of them. But if it's "too late", I believe it would be reasonable to allow cross-doc navigation iff the user gesture is present. |
|
I think amphtml/src/service/standard-actions-impl.js Lines 145 to 149 in ca175d7 Would any existing pages rely on the fact that |
Does |
Yes! At least according to amphtml/src/action-constants.js Lines 56 to 63 in ca175d7 I do still see this |
966135b to
e33090c
Compare
5c2c25f to
78f802e
Compare
|
I've made the updates, this should be ready for review |
78f802e to
f03cb04
Compare
cb063cd to
0c9138c
Compare
1e75aec to
756cc60
Compare
756cc60 to
805651a
Compare
src/service/standard-actions-impl.js
Outdated
| case 'goBack': | ||
| Services.historyForDoc(this.ampdoc).goBack(); | ||
| Services.historyForDoc(this.ampdoc).goBack( | ||
| /*canPerforWindowBack*/ !!args && args['navigate'] |
There was a problem hiding this comment.
Is args['navigate'] a boolean or a string? If string, what if I pass navigate=false?
There was a problem hiding this comment.
Great question! There is a full ParserTokenizer that will correctly discover the type as a boolean, so navigate=false works as expected.
I'm pretty sure the code that does this is:
amphtml/src/service/action-impl.js
Lines 1403 to 1407 in 805651a
I also verified this empirically since I don't understand the parser just yet
src/service/history-impl.js
Outdated
| return this.enque_(() => { | ||
| if (this.stackIndex_ <= 0) { | ||
| // Nothing left to pop. | ||
| if (this.stackIndex_ <= 0 && !canPerformWindowBack) { |
There was a problem hiding this comment.
For HistoryBindingVirtual, do viewers face-plant if they receive a negative stackIndex param?
There was a problem hiding this comment.
The SRP Viewer won't face-plant. I believe it'll just drop the request as invalid
|
Oh and remember to update documentation. :) |
…#26585) * history-impl: parameterize goBack * fixed test name * always use the binding * fix tests * improve doc * back to AMP.windowBack instead. * restore canPerformWindowBack * also test noarg * update to parameterized func * checktypes, use quoted prop * will updates * keep enthusiastic boolean conversion, constrain to ==true
Implements #5225