/
githubmirror
/
amphtml
Обзор
Документация
Войти
/
githubmirror
/
amphtml
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/core/window/index.js
25 строк
701 B
Ryan Cebulko
♻️ Migrate most of #core to pass TS typechecking (#37141)
09 дек 2021, 21:22
Не верифицирован
09 дек 2021, 21:22
58a1c29
Код
Авторство
О чём код?
/** * Externs declare that access `defaultView` from `document` or * `ownerDocument` is of type `(Window|null)` but most of our parameter types * assume that it is never null. This is OK in practice as we ever only get * null on disconnected documents or old IE. * This helper function casts it into just a simple Window return type. * * @param {?Window} winOrNull * @return {Window} */ export function toWin(winOrNull) { return /** @type {Window} */ (winOrNull); } /** * Returns the associated Window for a node. * * @param {Node} node * @return {Window} */ export function getWin(node) { return toWin( (node.ownerDocument || /** @type {Document} */ (node)).defaultView ); }