Skip to content

find more idiomatic way to detect attachShadow usage in the JSX compiler #258

@thescientist13

Description

@thescientist13

Current State

Currently, the JSX compiler does a naive check to detect if Declarative Shadow DOM is being used in a custom element definition

hasShadowRoot = moduleContents.slice(node.body.start, node.body.end).indexOf('this.attachShadow(') > 0;

The main downside to this is that it's a naive check of the contents, which could include comments. It should be more reliant on the AST to find a real usage of the attachShadow call

Desired State

It should use the AST and walk method to find this. Just spit balling...

hasShadowRoot = node.children.some((c) => {
  // find `attachShadow` using the AST instead
})

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    🔖 Ready

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions