Skip to content

Details component should not auto-initialize when imported #879

@alexgibson

Description

@alexgibson

Description

There's some code in the MzpDetails component that tries to auto-initialize some common selectors as soon as the code is parsed by the browser. This can cause issues now that we're explicitly importing/exporting JS as modules, since at the time this auto-initializing code runs global dependencies such as window.MzpSupports may not yet be available to reference.

Steps to reproduce

Given the following code, the auto-initializing code will fail:

import MzpSupports from '@mozilla-protocol/core/protocol/js/supports';
import MzpUtils from '@mozilla-protocol/core/protocol/js/utils';
import MzpDetails from '@mozilla-protocol/core/protocol/js/details';

window.MzpSupports = MzpSupports;
window.MzpUtils = MzpUtils;
window.MzpDetails = MzpDetails;

Expected result

MzpDetails should initialize on the class .mzp-c-details.

Actual result

The component is not initialized.

Instead of trying to run this code silently/automatically, we should probably make it explicit/manual instead

Environment

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🪲Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions