Skip to content

[Feature]: Support ShadowDOM for Page.content() #30816

Closed

Description

🚀 Feature Request

current Page.content() not include shadow dom content

Example

API:

await page.content({ serializableShadowRoots: true });

Related spec: https://html.spec.whatwg.org/#dom-parsing-and-serialization

Implement

const doctype = document.doctype
  ? new XMLSerializer().serializeToString(document.doctype)
  : '';
// https://html.spec.whatwg.org/#dom-parsing-and-serialization
if (!('getHTML' in Element.prototype)) {
  return `${doctype}${document.documentElement.outerHTML}`;
}
const body = (document.documentElement as any).getHTML({ serializableShadowRoots: true });
const uid = crypto.randomUUID();
document.documentElement.innerHTML = uid;
return `${doctype}${document.documentElement.outerHTML.replace(
  uid,
  body
)}`;

Motivation

Let the crawler(e.g: renderscript) grab everything

Activity

  1. TylerAHolden commented on Oct 26, 2024

    @TylerAHolden

    +1 Would definitely like to see this feature

  2. pavelfeldman commented on Sep 8, 2025

    @pavelfeldman
    Member

    Why was this issue closed?

    Thank you for your involvement. This issue was closed due to limited engagement (upvotes/activity), lack of recent activity, and insufficient actionability. To maintain a manageable database, we prioritize issues based on these factors.

    If you have additional information not present in this issue that you think will help prioritizing it, please open a new issue and reference this one. More support or clarity on its necessity may prompt a review. Your understanding and cooperation are appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions