Skip to content

Commit 5bd0813

Browse files
authored
Merge pull request #4 from bit-docs/remove-import-hack
Remove the <script type="module"> hack
2 parents 52aba63 + 631b260 commit 5bd0813

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

index.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,6 @@ module.exports = function() {
119119
if(data.html) {
120120
data.html = data.html.trim();
121121
}
122-
if (data.js && data.js.indexOf('import') > -1) {
123-
var jsAsModule = "<script type=\"module\">\n" + data.js + "\n</script>";
124-
data.html = data.html ? data.html + "\n\n" + jsAsModule : jsAsModule;
125-
data.js = "";
126-
data.editors = "1001";// HTML, Result, & Console
127-
}
128122
if(data) {
129123
cleanCodePenData(data);
130124
if(window.CREATE_CODE_PEN) {
@@ -143,10 +137,6 @@ module.exports = function() {
143137

144138
var jsCode = el.querySelector("[data-for=js] code");
145139
var jsText = jsCode ? jsCode.textContent.trim() : "";
146-
if (jsText) {
147-
htmlText += "\n<script type=\"module\">\n" + jsText + "\n</script>";
148-
jsText = "";
149-
}
150140

151141
var cssText = getStylesFromIframe( el.querySelector("iframe") );
152142

test.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,16 @@ describe("bit-docs-html-codepen-link", function() {
6060
codePen.click();
6161
});
6262
assert.deepEqual(createCallData, [{
63-
html: '<my-app></my-app>\n\n<script type="module">\nimport { Component } from "//unpkg.com/can@^5.0.0-pre.1/core.mjs";\nComponent\n</script>',
64-
js: '',
63+
html: '<my-app></my-app>',
64+
js: 'import { Component } from "//unpkg.com/can@^5.0.0-pre.1/core.mjs";\nComponent',
6565
js_module: true,
66-
editors: '1001',
66+
editors: '1011',
6767
css: 'my-app {color: "green";}'
6868
},
6969
{
70-
html: '<script type="module">\nimport {DefineMap} from "//unpkg.com/can@^5.0.0-pre.1/core.mjs";\nconsole.log( myCounter.count ) //-> 1\n</script>',
71-
js: '',
70+
js: 'import {DefineMap} from "//unpkg.com/can@^5.0.0-pre.1/core.mjs";\nconsole.log( myCounter.count ) //-> 1',
7271
js_module: true,
73-
editors: '1001'
72+
editors: '0011'
7473
}
7574
]);
7675

0 commit comments

Comments
 (0)