* Helper method to handle navigation to a local target, e.g. When a user * clicks an anchor link to a local hash - Go to section * 1 . * * @param {string} target * @return {!Promise}
(target)
| 162 | * @return {!Promise} |
| 163 | */ |
| 164 | replaceStateForTarget(target) { |
| 165 | devAssert(target[0] == '#', 'target should start with a #'); |
| 166 | const previousHash = this.ampdoc_.win.location.hash; |
| 167 | return this.push(() => { |
| 168 | this.ampdoc_.win.location.replace(previousHash || '#'); |
| 169 | }).then(() => { |
| 170 | this.binding_.replaceStateForTarget(target); |
| 171 | }); |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Get the fragment from the url or the viewer. |
no test coverage detected