Skip to content
This repository was archived by the owner on Nov 6, 2019. It is now read-only.
This repository was archived by the owner on Nov 6, 2019. It is now read-only.

Make Phosphor safe to load on the page more than once #443

@sccolbert

Description

@sccolbert

Forcing Phosphor to be a singleton on the page is "not nice" for projects which consume Phosphor. It means new functionality in Phosphor is not available for the users of those downstream projects until those projects update their dependencies. For Phosphor 2.0 (which should hopefully be the last major version of Phosphor) I think we can do better.

One idea that I have is to leverage Symbol.for('@phosphor/widgets@2.x') and tag the Widget prototype with that Symbol for each minor release. Since the Symbol is guaranteed to be global on the page, it would let duplicate prototypes function just fine, because we could guarantee they have the needed API. Instead of using the instanceof operator, we could have some convenience functions for checking the presence of the symbols.

This idea may have holes, but it's a good starting point I think.

CC @afshin @blink1073 @jasongrout

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions