Вопрос

I'd like to run a bookmarklet to capture the current state of a document (web page) as HTML. The document is built using Polymer, so most of the elements are inside shadow roots, which means that their contents are not included in the output of document.body.innerHTML.

Is it possible to export a JavaScript-generated document as HTML, including the content of Shadow DOM elements?

Это было полезно?

Решение

What you want is to capture the composed/rendered dom tree. Here are a few examples of doing this that may be useful:

The latter shows the <content>, which is probably not what you want. But you could easily modify it to only contain the rendered nodes.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top