Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] querySelector and querySelectorAll not working within <plasmo-csui> element #1147

Open
2 of 3 tasks
smilingkylan opened this issue Dec 21, 2024 · 2 comments
Open
2 of 3 tasks
Labels
bug Something isn't working

Comments

@smilingkylan
Copy link

What happened?

For some reason when I use getInlineAnchorList to mount components in the shadow dom, they apparently are not able to be queried with a simple document.querySelector. Please see attached videos.

query-selector-fail.mov
query-selector-fail-2.mov

Version

Latest

What OS are you seeing the problem on?

MacOSX

What browsers are you seeing the problem on?

Chrome

Relevant log output

See attached videos

(OPTIONAL) Contribution

  • I would like to fix this BUG via a PR

Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I checked the current issues for duplicate problems.
@smilingkylan smilingkylan added the bug Something isn't working label Dec 21, 2024
@smilingkylan
Copy link
Author

Sorry for the content on the X.com feed, that's just the nature of building an extension on top of X

@Can-Chen
Copy link

function findAllShadowRoots() {
    const allShadowRoots = [];
    function traverse(node) {
        if (node.shadowRoot) {
            allShadowRoots.push(node.shadowRoot);
        }
        const childNodes = node.childNodes;
        for (let i = 0; i < childNodes.length; i++) {
            traverse(childNodes[i]);
        }
    }
    traverse(document.body);
    return allShadowRoots;
}

const shadowRoots = findAllShadowRoots();
const result = shadowRoots.find(el => el.querySelector('someButton'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants