@@ -164,9 +164,11 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
164164 return popContext ( state ) ;
165165 } else if ( supportsAtComponent && / @ c o m p o n e n t / . test ( type ) ) {
166166 return pushContext ( state , stream , "atComponentBlock" ) ;
167- } else if ( / @ ( m e d i a | s u p p o r t s | ( - m o z - ) ? d o c u m e n t ) / . test ( type ) ) {
167+ } else if ( / ^ @ ( - m o z - ) ? d o c u m e n t $ / . test ( type ) ) {
168+ return pushContext ( state , stream , "documentTypes" ) ;
169+ } else if ( / ^ @ ( m e d i a | s u p p o r t s | ( - m o z - ) ? d o c u m e n t | i m p o r t ) $ / . test ( type ) ) {
168170 return pushContext ( state , stream , "atBlock" ) ;
169- } else if ( / @ ( f o n t - f a c e | c o u n t e r - s t y l e ) / . test ( type ) ) {
171+ } else if ( / ^ @ ( f o n t - f a c e | c o u n t e r - s t y l e ) / . test ( type ) ) {
170172 state . stateArg = type ;
171173 return "restricted_atBlock_before" ;
172174 } else if ( / ^ @ ( - ( m o z | m s | o | w e b k i t ) - ) ? k e y f r a m e s $ / . test ( type ) ) {
@@ -259,17 +261,24 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
259261 return pass ( type , stream , state ) ;
260262 } ;
261263
264+ states . documentTypes = function ( type , stream , state ) {
265+ if ( type == "word" && documentTypes . hasOwnProperty ( stream . current ( ) ) ) {
266+ override = "tag" ;
267+ return state . context . type ;
268+ } else {
269+ return states . atBlock ( type , stream , state ) ;
270+ }
271+ } ;
272+
262273 states . atBlock = function ( type , stream , state ) {
263274 if ( type == "(" ) return pushContext ( state , stream , "atBlock_parens" ) ;
264- if ( type == "}" ) return popAndPass ( type , stream , state ) ;
275+ if ( type == "}" || type == ";" ) return popAndPass ( type , stream , state ) ;
265276 if ( type == "{" ) return popContext ( state ) && pushContext ( state , stream , allowNested ? "block" : "top" ) ;
266277
267278 if ( type == "word" ) {
268279 var word = stream . current ( ) . toLowerCase ( ) ;
269280 if ( word == "only" || word == "not" || word == "and" || word == "or" )
270281 override = "keyword" ;
271- else if ( documentTypes . hasOwnProperty ( word ) )
272- override = "tag" ;
273282 else if ( mediaTypes . hasOwnProperty ( word ) )
274283 override = "attribute" ;
275284 else if ( mediaFeatures . hasOwnProperty ( word ) )
0 commit comments