Skip to content

bug: In spec tests : ReferenceError: ShadowRoot is not defined #3260

Closed
ionic-team/ionic-framework
#29666

Description

@ryuran

Prerequisites

Stencil Version

2.14.0

Current Behavior

this.el.getRootNode() instanceof ShadowRoot
I try to know if my custom component is in a shadowDOM.
It works well but not in specs test.
I have this error ReferenceError: ShadowRoot is not defined

Expected Behavior

No error in test when we use ShadowRoot

Steps to Reproduce

Try to test if the host element is in a shadowDOM context
this.el.getRootNode() instanceof ShadowRoot

Then run unit tests.

Code Reproduction URL

https://github.com/ryuran/stencil-bugs

Additional Information

  • npm i
  • npm test

Workaround

Mock:

global.DocumentFragment = class DocumentFragment extends Node {};
global.ShadowRoot = class ShadowRoot extends DocumentFragment {};

Activity

  1. added
    Bug: Validated
    and removed on Mar 7, 2022
  2. rwaskiewicz commented on Mar 7, 2022

    @rwaskiewicz
    Member

    Thanks! I've verified this is an issue and have labeled this to be ingested into our team backlog!

  3. reessm01 commented on Mar 24, 2022

    @reessm01

    I just wanted to chime in that I was enduring shadowRoot not defined as well (no reference or clue or even what is different as the error information isn't helpful at all), however the work around provided here fixed it.

  4. tanner-reits commented on Jun 26, 2024

    @tanner-reits
    Contributor

    A fix for this was included in today's v4.19.0 release!

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

Metadata

Metadata

Labels

Bug: Validated

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions