Skip to content

Minification performed by bundlers (e.g., esm.sh) breaks getSuperMethod() #94

@DmitrySharabin

Description

@DmitrySharabin

getSuperMethod() relies on Function.name (which doesn't survive minification) to walk the prototype chain:

export function getSuperMethod (obj, currentMethod) {
return getSuperMember(obj, currentMethod.name, currentMethod);
}

The shadow plugin's attachShadow() function is passed to getSuperMethod(), which internally does currentMethod.name to find HTMLElement.prototype.attachShadow:

const _attachShadow = getSuperMethod(this, attachShadow);

esm.sh minifies attachShadowh, so h.name === "h". The lookup for attachShadow up the prototype chain fails, getSuperMethod() returns undefined, and the shadow root is never created:

return (this[shadowRoot] = null);

As a result, for example, none of the color elements work via esm.sh.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions