/
githubmirror
/
amphtml
Обзор
Документация
Войти
/
githubmirror
/
amphtml
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
build-system/tasks/visual-diff/snippets/remove-no-script.js
22 строки
688 B
Daniel Rozenberg
🏗 Visual diff updates and fixes (#35942)
03 сен 2021, 17:52
Не верифицирован
03 сен 2021, 17:52
ce36ba5
Код
Авторство
О чём код?
/** * @fileoverview This file is executed via Puppeteer's page.evaluate on a * document to remove all <noscript> tags, from the main document and iframes. * This makes for cleaner diffs and prevents "double-execution" of AMP scripts * when enableJavaScript=false. */ /** * Removes <noscript> elements from doc and its iframes. * @param {Document} doc document to operate on recursively. */ function removeNoscript(doc) { doc.querySelectorAll('noscript').forEach((node) => node./*OK*/ remove()); doc.body.querySelectorAll('iframe').forEach((iframe) => { if (iframe.contentDocument) { removeNoscript(iframe.contentDocument); } }); } removeNoscript(document);