Skip to content

Using storybook decorators with a "wrapper" custom element in the decorator breaks. #57

@rstoneIDBS

Description

@rstoneIDBS

First some background :)

I'm using wc-storybook-helpers to add documentation to a component library that has multiple versions of components, i.e. we have legacy Polymer based components and new Lit based components which live in separate areas of the package. This means that we have multiple components with the same tag name, the consumers of our library are new & old projects - the old continue to use the Polymer components and new one use the Lit components. The plan is to gradually migrate all our apps off the Polymer components but thats some way down the line.

To allow both versions of the components to appear in the same Storybook I've been experimenting with using @webcomponents/scoped-custom-element-registry to scope the newer components via a Storybook decorator, i.e. I create a wrapper component that contains the scoped registry and then register the Lit based components there. This mostly works :)

However I see the following error from wc-storybook-helpers:
Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'. at wc-storybook-helpers.js:819:48

This is because 'syncControls' is trying to find the custom element tag via a document.querySelector. This obviously fails in my case because the element exists within the shadow DOM of my Storybook decorator wrapper element.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions