File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -6,14 +6,20 @@ var types = {
6
6
html : function htmlType ( text ) {
7
7
8
8
var result ;
9
+ var HTML = text ;
9
10
10
11
text . replace ( scriptRegExp , function ( match , attrs , code ) {
11
12
12
13
var matchTest = attrs . match ( moduleTest ) ;
13
14
14
- if ( matchTest && ! srcTest . test ( attrs ) ) {
15
+ // This has a src="". We look for codepen-external
16
+ if ( srcTest . test ( attrs ) ) {
15
17
16
- var HTML = text . replace ( match , "" ) . trim ( ) ;
18
+ }
19
+ // It doesn't have a src, so we assume this has a body
20
+ else if ( matchTest ) {
21
+
22
+ HTML = HTML . replace ( match , "" ) . trim ( ) ;
17
23
var CSS ;
18
24
var styleResults = HTML . match ( styleRegExp ) ;
19
25
if ( styleResults ) {
Original file line number Diff line number Diff line change @@ -114,4 +114,18 @@ describe("bit-docs-html-codepen-link", function() {
114
114
assert . equal ( data . js . trim ( ) , 'const element = <h1>Hello, world!</h1>;' ) ;
115
115
assert . equal ( data . js_pre_processor , 'babel' ) ;
116
116
} ) ;
117
+
118
+ it ( "is able to create external js" , function ( ) {
119
+ var data = codepenData . html ( `
120
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/6.2.1/rxjs.umd.js" codepen-external></script>
121
+ <script src="https://foo.com" codepen-external></script>
122
+ <script type="typescript">
123
+ const {Observable} = rxjs;
124
+ </script>
125
+ ` ) ;
126
+ assert . equal ( data . js . trim ( ) , 'const {Observable} = rxjs;' ) ;
127
+ assert . equal ( data . js_pre_processor , 'typescript' ) ;
128
+ assert . equal ( data . js_external , 'https://cdnjs.cloudflare.com/ajax/libs/rxjs/6.2.1/rxjs.umd.js;https://foo.com' ) ;
129
+ assert . equal ( data . html , undefined , "no html" )
130
+ } ) ;
117
131
} ) ;
You can’t perform that action at this time.
0 commit comments