MCPcopy Index your code
hub / github.com/ampproject/amphtml / masterSelection

Function masterSelection

3p/ampcontext-integration.js:15–34  ·  view source on GitHub ↗
(win, type)

Source from the content-addressed store, hash-verified

13 * @return {!Window}
14 */
15export function masterSelection(win, type) {
16 type = type.toLowerCase();
17 // The master has a special name.
18 const masterName = 'frame_' + type + '_master';
19 let master;
20 try {
21 // Try to get the master from the parent. If it does not
22 // exist yet we get a security exception that we catch
23 // and ignore.
24 master = win.parent.frames[masterName];
25 } catch (expected) {
26 /* ignore */
27 }
28 if (!master) {
29 // No master yet, rename ourselves to be master. Yaihh.
30 win.name = masterName;
31 master = win;
32 }
33 return master;
34}
35
36export class IntegrationAmpContext extends AbstractAmpContext {
37 /** @override */

Callers 2

master_Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected