Skip to content

Commit 019f8ea

Browse files
shakyShaneShane Osbourne
andauthored
fix: remove document.write (#2019)
* fix: remove document.write * fixes --------- Co-authored-by: Shane Osbourne <[email protected]>
1 parent 3b0581e commit 019f8ea

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

packages/browser-sync/lib/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ module.exports = {
1010
baseDir: path.join(__dirname, "control-panel")
1111
},
1212
templates: {
13-
scriptTag: path.join(__dirname, "..", "templates/script-tags.tmpl"),
13+
scriptTag: path.join(__dirname, "..", "templates/script-tags.html"),
1414
scriptTagSimple: path.join(
1515
__dirname,
1616
"..",
17-
"templates/script-tags-simple.tmpl"
17+
"templates/script-tags-simple.html"
1818
),
1919
connector: path.join(__dirname, "..", "templates/connector.tmpl")
2020
},
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<script id="__bs_script__">//<![CDATA[
2+
(function() {
3+
try {
4+
var script = document.createElement('script');
5+
if ('%async%') {
6+
script.async = true;
7+
}
8+
script.src = '%script%'.replace("HOST", location.hostname);
9+
if (document.body) {
10+
document.body.appendChild(script);
11+
}
12+
} catch (e) {
13+
console.error("Browsersync: could not append script tag", e);
14+
}
15+
})()
16+
//]]></script>

packages/browser-sync/templates/script-tags.tmpl

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/browser-sync/test/specs/e2e/e2e.options.script.async.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe("E2E script with/without async attribute", function() {
2121
}
2222
};
2323
browserSync(config, function(err, bs) {
24-
assert.notInclude(bs.options.get("snippet"), "async");
24+
assert.notInclude(bs.options.get("snippet"), "'async'");
2525
bs.cleanup();
2626
done();
2727
});

0 commit comments

Comments
 (0)