MCPcopy
hub / github.com/ampproject/amphtml / getHostWindow_

Method getHostWindow_

3p/ampcontext.js:388–398  ·  view source on GitHub ↗

* Calculate the hostWindow * @private * @return {!Window}

()

Source from the content-addressed store, hash-verified

386 * @return {!Window}
387 */
388 getHostWindow_() {
389 const sentinelMatch = this.sentinel.match(/((\d+)-\d+)/);
390 devAssert(sentinelMatch, 'Incorrect sentinel format');
391 const depth = Number(sentinelMatch[2]);
392 const ancestors = [];
393 for (let win = this.win_; win && win != win.parent; win = win.parent) {
394 // Add window keeping the top-most one at the front.
395 ancestors.push(win.parent);
396 }
397 return ancestors[ancestors.length - 1 - depth];
398 }
399
400 /**
401 * Checks to see if there is a window variable assigned with the

Callers 1

constructorMethod · 0.95

Calls 2

devAssertFunction · 0.90
pushMethod · 0.45

Tested by

no test coverage detected