File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ var scriptRegExp = /<script\s([^>]+)>([\s\S]*?)<\/script>/ig;
2
2
var styleRegExp = / < s t y l e > ( [ \s \S ] * ?) < \/ s t y l e > / i;
3
3
var moduleTest = / t y p e = [ " ' ] ( [ \w \/ ] + ) [ " ' ] / ;
4
4
var srcTest = / s r c = / ;
5
+ var DEFAULT_EDITORS = "0011" ;
6
+
5
7
var types = {
6
8
html : function htmlType ( text ) {
7
9
@@ -40,27 +42,36 @@ var types = {
40
42
}
41
43
}
42
44
} ) ;
45
+
46
+ // If there are no scripts the should at least be HTML
47
+ if ( ! result ) {
48
+ result = {
49
+ html : HTML ,
50
+ editors : DEFAULT_EDITORS
51
+ }
52
+ }
53
+
43
54
return result ;
44
55
} ,
45
56
js : function ( text ) {
46
57
return {
47
58
js : text ,
48
59
js_module : true ,
49
- editors : "0011"
60
+ editors : DEFAULT_EDITORS
50
61
} ;
51
62
} ,
52
63
typescript : function ( text ) {
53
64
return {
54
65
js : text ,
55
66
js_pre_processor : "typescript" ,
56
- editors : "0011"
67
+ editors : DEFAULT_EDITORS
57
68
} ;
58
69
} ,
59
70
jsx : function ( text ) {
60
71
return {
61
72
js : text ,
62
73
js_pre_processor : "babel" ,
63
- editors : "0011"
74
+ editors : DEFAULT_EDITORS
64
75
} ;
65
76
}
66
77
} ;
Original file line number Diff line number Diff line change @@ -128,4 +128,13 @@ describe("bit-docs-html-codepen-link", function() {
128
128
assert . equal ( data . js_external , 'https://cdnjs.cloudflare.com/ajax/libs/rxjs/6.2.1/rxjs.umd.js;https://foo.com' ) ;
129
129
assert . equal ( data . html , undefined , "no html" )
130
130
} ) ;
131
+
132
+ it ( "works when there is no js" , function ( ) {
133
+ var data = codepenData . html ( `
134
+ <div>Hello world</div>
135
+ ` )
136
+
137
+ assert ( data , "got data" ) ;
138
+ assert . equal ( data . html . trim ( ) , "<div>Hello world</div>" ) ;
139
+ } )
131
140
} ) ;
You can’t perform that action at this time.
0 commit comments