Roll forward: Implement anchor href expand on document click with X/Y support#5053
Roll forward: Implement anchor href expand on document click with X/Y support#5053jridgewell merged 66 commits intoampproject:masterfrom google:a4a_clickUrlExpand
Conversation
…nt target rewrite for shadowDom elements; was not binding whether capture to click handler properly. Test coverage for fixes to be added shortly
…y offset, look for existence of event.path and use event.target which should match host element
The previous change was made in error (wrong branch).
…nt target rewrite for shadowDom elements; was not binding whether capture to click handler properly. Test coverage for fixes to be added shortly
…y offset, look for existence of event.path and use event.target which should match host element
…nt target rewrite for shadowDom elements; was not binding whether capture to click handler properly. Test coverage for fixes to be added shortly
…y offset, look for existence of event.path and use event.target which should match host element
src/service/url-replacements-impl.js
Outdated
| * Enforces synchronous evaluation. | ||
| * @param {string} startEvent | ||
| * @param {string=} endEvent | ||
| * @return {string|undefined} undefined if API is not available, empty string |
|
@keithwrightbos thanks a lot! Couple of smaller comments from my side and LGTM. I'm leaving the final LGTM to @jridgewell |
|
@jridgewell PTAL. Note this also addresses issue #5113 |
src/service/url-replacements-impl.js
Outdated
| const timingInfo = this.win_['performance'] | ||
| && this.win_['performance']['timing']; | ||
| getTimingDataAsync_(startEvent, endEvent) { | ||
| let metric = this.getTimingDataSync_(startEvent, endEvent); |
There was a problem hiding this comment.
do not need to unnecessarily wait for load
We're returning a promise, though. Even if it's resolved sync (Promise.resolve(metric)), the caller can't get it's value until ~.1ms later. Adding another sync resolved Promise (loadPromise(this.win_)) only adds another ~.1ms delay.
This can definitely be in another PR, though.
src/service/url-replacements-impl.js
Outdated
| // Metric is not yet available. Retry after a delay. | ||
| return loadPromise(this.win_).then(() => { | ||
| metric = this.getTimingDataSync_(startEvent, endEvent); | ||
| return metric === '' ? undefined : metric; |
There was a problem hiding this comment.
Nitpick: metric || undefined
There was a problem hiding this comment.
Done, collapse to return this.getTimingDataSync_(startEvent, endEvent);
src/service/url-replacements-impl.js
Outdated
| if (!navigationInfo || navigationInfo[attribute] === undefined) { | ||
| // PerformanceNavigation interface is not supported or attribute is not implemented. | ||
| return Promise.resolve(); | ||
| return ; |
There was a problem hiding this comment.
Nitpick: no spacing before ;.
|
@jridgewell PTAL. Thanks |
|
LGTM. |
This "rollsback" ampproject#5053, since it won't cleanly revert. To rollforward, revert only this commit. /cc @keithwrightbos
This "rollsback" #5053, since it won't cleanly revert. To rollforward, revert only this commit. /cc @keithwrightbos
A more limited (to A4A) exposure of the work in ampproject#5053. - Implements ability to provide a white list of replacements for a given operation. - Moves the click handler from a global position to A4A specific code. - Switches to simpler click position implementation (just `pageX/Y`). This is currently incorrect, but will be correct after A4A moves to friendly iframes from ShadowDOM. Should help with ampproject#5205 and ampproject#4078. Related to ampproject#4891.
A more limited (to A4A) exposure of the work in ampproject#5053. - Implements ability to provide a white list of replacements for a given operation. - Moves the click handler from a global position to A4A specific code. - Switches to simpler click position implementation (just `pageX/Y`). This is currently incorrect, but will be correct after A4A moves to friendly iframes from ShadowDOM. Should help with ampproject#5205 and ampproject#4078. Related to ampproject#4891.
…A. (ampproject#5275) A more limited (to A4A) exposure of the work in ampproject#5053. - Implements ability to provide a white list of replacements for a given operation. - Moves the click handler from a global position to A4A specific code. - Switches to simpler click position implementation (just `pageX/Y`).
… support (ampproject#5053) * Implement anchor href expand on document click with X/Y support * Fixes after full stack testing: need to look at event path due to event target rewrite for shadowDom elements; was not binding whether capture to click handler properly. Test coverage for fixes to be added shortly * update tests; instead of looking for shadowRoot boundary to update x/y offset, look for existence of event.path and use event.target which should match host element * slight refactor for readability * fix javadoc error * Update amp-ad-network-doubleclick-impl.md * Reverting doc changes The previous change was made in error (wrong branch). * changes in response to PR review * update var substititions documentation * make capture listener actually use capture! * remove unnecessary else clause * fix pull conflicts * Fixes after full stack testing: need to look at event path due to event target rewrite for shadowDom elements; was not binding whether capture to click handler properly. Test coverage for fixes to be added shortly * update tests; instead of looking for shadowRoot boundary to update x/y offset, look for existence of event.path and use event.target which should match host element * slight refactor for readability * fix javadoc error * changes in response to PR review * update var substititions documentation * make capture listener actually use capture! * remove unnecessary else clause * fix test failure due to issue after merge * address PR comments * Implement anchor href expand on document click with X/Y support * Fixes after full stack testing: need to look at event path due to event target rewrite for shadowDom elements; was not binding whether capture to click handler properly. Test coverage for fixes to be added shortly * update tests; instead of looking for shadowRoot boundary to update x/y offset, look for existence of event.path and use event.target which should match host element * slight refactor for readability * fix javadoc error * changes in response to PR review * update var substititions documentation * make capture listener actually use capture! * remove unnecessary else clause * fix pull conflicts * Fixes after full stack testing: need to look at event path due to event target rewrite for shadowDom elements; was not binding whether capture to click handler properly. Test coverage for fixes to be added shortly * update tests; instead of looking for shadowRoot boundary to update x/y offset, look for existence of event.path and use event.target which should match host element * slight refactor for readability * changes in response to PR review * fix test failure due to issue after merge * Revert "reenable history tests (ampproject#4758)" This reverts commit 1375883. * Revert "Reverting doc changes" This reverts commit 8d8c6dd. * Revert "Small Validator Updates, including blacklisting __amp_source_origin for URLs. (ampproject#4781)" This reverts commit bffeb2d. * Revert "Remove video-id from the amp-youtube extension runtime. This attr had (ampproject#4507)" This reverts commit 8d1799d. * Revert unintentionally added files. * Revert unintentionally added file. * Fix test failure from latest merge * Fix conflict and lint errors * Fix lint errors, type check failures, and test failures * Fix test failures * Remove Math.random override causing breakages in other tests * PR comment feedback * PR review changes * PR code review * PR review * Address error in issue ampproject#5113 * PR review
This "rollsback" ampproject#5053, since it won't cleanly revert. To rollforward, revert only this commit. /cc @keithwrightbos
…A. (ampproject#5275) A more limited (to A4A) exposure of the work in ampproject#5053. - Implements ability to provide a white list of replacements for a given operation. - Moves the click handler from a global position to A4A specific code. - Switches to simpler click position implementation (just `pageX/Y`).
…A. (ampproject#5275) A more limited (to A4A) exposure of the work in ampproject#5053. - Implements ability to provide a white list of replacements for a given operation. - Moves the click handler from a global position to A4A specific code. - Switches to simpler click position implementation (just `pageX/Y`).
Attempt to roll forward PR #4773 which was reverted due to test failures which have subsequently been addressed.