File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ var languageHTML = /language-(\w+)/;
5
5
function cleanCodePenData ( data ) {
6
6
if ( docObject . codepen ) {
7
7
docObject . codepen . forEach ( function ( replacement ) {
8
+ if ( data . html ) {
9
+ data . html = data . html . split ( replacement [ 0 ] ) . join ( replacement [ 1 ] ) ;
10
+ }
8
11
if ( data . js ) {
9
12
data . js = data . js . split ( replacement [ 0 ] ) . join ( replacement [ 1 ] ) ;
10
13
}
@@ -115,6 +118,10 @@ module.exports = function() {
115
118
}
116
119
if ( data . html ) {
117
120
data . html = data . html . trim ( ) ;
121
+ if ( data . js ) {
122
+ data . html += "\n\n<script type=\"module\">\n" + data . js + "\n</script>" ;
123
+ data . js = "" ;
124
+ }
118
125
}
119
126
if ( data ) {
120
127
cleanCodePenData ( data ) ;
@@ -134,6 +141,10 @@ module.exports = function() {
134
141
135
142
var jsCode = el . querySelector ( "[data-for=js] code" ) ;
136
143
var jsText = jsCode ? jsCode . textContent . trim ( ) : "" ;
144
+ if ( jsText ) {
145
+ htmlText += "\n<script type=\"module\">\n" + jsText + "\n</script>" ;
146
+ jsText = "" ;
147
+ }
137
148
138
149
var cssText = getStylesFromIframe ( el . querySelector ( "iframe" ) ) ;
139
150
Original file line number Diff line number Diff line change @@ -60,8 +60,8 @@ describe("bit-docs-html-codepen-link", function() {
60
60
codePen . click ( ) ;
61
61
} ) ;
62
62
assert . deepEqual ( createCallData , [ {
63
- html : '<my-app></my-app>' ,
64
- js : 'import { Component } from "//unpkg.com/can@^5.0.0-pre.1/core.mjs";\nComponent ' ,
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 : '' ,
65
65
js_module : true ,
66
66
editors : '1011' ,
67
67
css : 'my-app {color: "green";}'
You can’t perform that action at this time.
0 commit comments