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

Move all side effects to exported init function #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jeanfredrik
Copy link

I’m creating a package that uses yett under the hood and the way it requires an assigned whitelist/blacklist before the package is included makes it hard to use it with import/export because the load order can’t always be guaranteed. This pull request moves all immediate side-effects to an init function that’s exported along with the current unblock function. It still allows setting a whitelist/blacklist on window but also accepts it as an argument to the init function.

Usage before:

    <script>
        window.YETT_BLACKLIST = [
            /script\.js$/
        ]
    </script>
    <script src="yett.min.js"></script>

Usage after:

    <script src="yett.min.js"></script>
    <script>
        yett.init({
            blacklist: [
                /script\.js$/
            ]
        })
    </script>

It would be a breaking change though because nothing will happen unless init is called. If that’s a problem there could perhaps be separate builds for browser and modules.

Tests pass.

@aoumiri
Copy link

aoumiri commented Jun 9, 2020

Exactly what I had in mind when trying this superb library, hope it gets released soon 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants