Skip to content

bug: adoptedStyleSheets's mutable before chrome 99 #6326

@liuwin7

Description

@liuwin7

Prerequisites

Stencil Version

4.33.0

Current Behavior

App will crash when running on chrome < 99.

https://github.com/stenciljs/core/src/utils/shadow-root.ts

  if (globalStyleSheet) shadowRoot.adoptedStyleSheets.push(globalStyleSheet);

https://github.com/stenciljs/core/src/runtime/styles.ts

      styleContainerNode.adoptedStyleSheets.push(style);

Reffer:
1, https://blog.chromium.org/2022/02/chrome-99-css-cascade-layers-new-picker.html#:~:text=document.adoptedStyleSheets%20is%20Now%20Mutable
2. https://chromestatus.com/feature/5638996492288000

Expected Behavior

Not crash when using chrome < 99

System Info

TypeError: Cannot add property 0, object is not extensible
    at Array.push (<anonymous>)
    at HTMLElement.createShadowRoot (:8100/node_modules/.vite/deps/chunk-HEIOVAU6.js?v=d73e29c9:528)
    at HTMLElement.__attachShadow (:8100/node_modules/.vite/deps/chunk-HEIOVAU6.js?v=d73e29c9:3706)

Steps to Reproduce

Using Chrome < 99, it will reproduce

Code Reproduction URL

No

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions