@@ -14,6 +14,8 @@ riot.parsers = {
1414 }
1515 }
1616}
17+ // 4 the nostalgics
18+ riot . parsers . js . coffeescript = riot . parsers . js . coffee
1719
1820
1921var BOOL_ATTR = ( 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,default,' +
@@ -44,7 +46,8 @@ var BOOL_ATTR = ('allowfullscreen,async,autofocus,autoplay,checked,compact,contr
4446 HTML_COMMENT = / < ! - - .* ?- - > / g,
4547 CLOSED_TAG = / < ( [ \w \- ] + ) ( [ ^ > ] * ) \/ \s * > / g,
4648 LINE_COMMENT = / ^ \s * \/ \/ .* $ / gm,
47- JS_COMMENT = / \/ \* [ ^ \x00 ] * ?\* \/ / gm
49+ JS_COMMENT = / \/ \* [ ^ \x00 ] * ?\* \/ / gm,
50+ INPUT_NUMBER = / ( < i n p u t \s [ ^ > ] * ?) t y p e = [ ' " ] n u m b e r [ ' " ] / gm
4851
4952function mktag ( name , html , css , attrs , js ) {
5053 return 'riot.tag(\''
@@ -68,6 +71,9 @@ function compileHTML(html, opts, type) {
6871 // strip comments
6972 html = html . trim ( ) . replace ( HTML_COMMENT , '' )
7073
74+ // input type=numbr
75+ html = html . replace ( INPUT_NUMBER , '$1riot-type=' + brackets ( 0 ) + '"number"' + brackets ( 1 ) ) // fake expression
76+
7177 // alter special attribute names
7278 html = html . replace ( SET_ATTR , function ( full , name , _ , expr ) {
7379 if ( expr . indexOf ( brackets ( 0 ) ) >= 0 ) {
@@ -131,7 +137,7 @@ function riotjs(js) {
131137 var end = / [ { } ] / . exec ( l . slice ( - 1 ) ) ,
132138 m = end && / ( \s + ) ( [ \w ] + ) \s * \( ( [ \w , \s ] * ) \) \s * \{ / . exec ( line )
133139
134- if ( m && ! / ^ ( i f | w h i l e | s w i t c h | f o r ) $ / . test ( m [ 2 ] ) ) {
140+ if ( m && ! / ^ ( i f | w h i l e | s w i t c h | f o r | c a t c h ) $ / . test ( m [ 2 ] ) ) {
135141 lines [ i ] = m [ 1 ] + 'this.' + m [ 2 ] + ' = function(' + m [ 3 ] + ') {'
136142
137143 // foo() { }
@@ -160,8 +166,9 @@ function riotjs(js) {
160166function scopedCSS ( tag , style , type ) {
161167 return style . replace ( CSS_COMMENT , '' ) . replace ( CSS_SELECTOR , function ( m , p1 , p2 ) {
162168 return p1 + ' ' + p2 . split ( / \s * , \s * / g) . map ( function ( sel ) {
163- var s = sel . replace ( / : s c o p e \s * / , '' )
164- return sel [ 0 ] == '@' ? sel : tag + ' ' + s + ', [riot-tag="' + tag + '"] ' + s
169+ var s = sel . trim ( ) . replace ( / : s c o p e \s * / , '' )
170+ return s [ 0 ] == '@' || s == 'from' || s == 'to' || / % $ / . test ( s ) ? s :
171+ tag + ' ' + s + ', [riot-tag="' + tag + '"] ' + s
165172 } ) . join ( ',' )
166173 } ) . trim ( )
167174}
@@ -216,7 +223,7 @@ function compile(src, opts) {
216223 style = ''
217224
218225 html = html . replace ( STYLE , function ( _ , fullType , _type , _style ) {
219- if ( fullType && 'scoped' == fullType . trim ( ) ) styleType = 'scoped-css'
226+ if ( fullType && fullType . trim ( ) == 'scoped' ) styleType = 'scoped-css'
220227 else if ( _type ) styleType = _type . replace ( 'text/' , '' )
221228 style = _style
222229 return ''
@@ -273,7 +280,7 @@ function compileScripts(fn) {
273280 fn && fn ( )
274281 }
275282
276- if ( ! scriptsAmount ) {
283+ if ( ! scriptsAmount ) {
277284 done ( )
278285 } else {
279286 ; [ ] . map . call ( scripts , function ( script ) {
0 commit comments