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

rxjs(umd file) will pollute global/window variable #4427

Closed
Aqours opened this issue Dec 17, 2018 · 0 comments · Fixed by #4487
Closed

rxjs(umd file) will pollute global/window variable #4427

Aqours opened this issue Dec 17, 2018 · 0 comments · Fixed by #4487
Labels
bug Confirmed bug

Comments

@Aqours
Copy link

Aqours commented Dec 17, 2018

Bug Report

Current Behavior
UMD rxjs file will inject global variable $jscomp to global/window.

Reproduction

test code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Variable Leaked</title>
    <style>
        #app {
            margin: 2em;
            padding: 1em;
            font-family: "Roboto Mono", "Source Code Pro", monospace;
            font-weight: 500;
            font-size: 1.125rem;
            line-height: 1.6;
        }
    </style>
</head>
<body>

<div id="app"></div>

<script>
    document.a = Object.keys(window);
</script>

<script src="https://unpkg.com/rxjs@6.3.3/bundles/rxjs.umd.min.js"></script>

<script>
    document.b = Object.keys(window);
    document.c = {};
    document.d = [];
    document.a.forEach(x => {
        document.c[x] = true;
    });
    document.b.forEach(x => {
        if (!document.c[x]) {
            document.d.push(x);
        }
    });

    (function(leaked, fragment) {
        console.log(leaked);
        leaked.reduce((p, c) => {
            p.appendChild(document.createTextNode(c));
            p.appendChild(document.createElement('br'));
            return p;
        }, fragment);
        self.app.appendChild(fragment);
    })(document.d, document.createDocumentFragment());
</script>

</body>
</html>

Expected behavior
UMD rxjs file will only inject global variable rxjs to global/window.

Environment

  • Runtime: n/a
  • RxJS version: 6.3.3
  • (If bug is related) Loader, build configuration: [e.g webpack, angular-cli version, config]

Possible Solution

Using --isolation_mode="IIFE" or --output_wrapper="(function(){%output%)).call(this);" flag to Google Closure Compiler which will not preserve previous IIFE. (See Flags-and-Options)

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

@kwonoj kwonoj added the bug Confirmed bug label Dec 17, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Mar 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Confirmed bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants