/
githubmirror
/
amphtml
Обзор
Документация
Войти
/
githubmirror
/
amphtml
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/inabox/utils.js
47 строк
1 KB
Ryan Cebulko
♻️ Move files into #core, #utils to enable tsc typechecking (#36277)
07 окт 2021, 23:26
Не верифицирован
07 окт 2021, 23:26
b6d1550
Код
Авторство
О чём код?
import {Services} from '#service'; import {createCustomEvent} from '#utils/event-helper'; import {whenContentIniLoadMeasure} from '../ini-load'; /** * Registers ini-load listener that will fire custom 'amp-ini-load' event * on window (accessible if creative is friendly to ad tag) and postMessage to * window parent. * @param {!../service/ampdoc-impl.AmpDoc} ampdoc */ export function registerIniLoadListener(ampdoc) { const {win} = ampdoc; const root = ampdoc.getRootNode(); whenContentIniLoadMeasure( ampdoc, win, Services.viewportForDoc(ampdoc).getLayoutRect( root.documentElement || root.body || root ) ).then(() => { win.dispatchEvent( createCustomEvent(win, 'amp-ini-load', /* detail */ null, {bubbles: true}) ); if (win.parent) { win.parent./*OK*/ postMessage('amp-ini-load', '*'); } }); } /** * Function to get the amp4ads-identifier from the meta tag on the document * @param {!Window} win * @return {?string} */ export function getA4AId(win) { const a4aIdMetaTag = win.document.head.querySelector( 'meta[name="amp4ads-id"]' ); if (a4aIdMetaTag) { return a4aIdMetaTag.getAttribute('content'); } return null; }