@@ -24,7 +24,7 @@ var CodeMirror = (function() {
2424 '<div style="overflow: hidden; position: relative; width: 1px; height: 0px;">' + // Wraps and hides input textarea
2525 '<textarea style="position: absolute; padding: 0; width: 1px;" wrap="off" ' +
2626 'autocorrect="off" autocapitalize="off"></textarea></div>' +
27- '<div class="CodeMirror-scroll cm-s-' + options . theme + ' ">' +
27+ '<div class="CodeMirror-scroll">' +
2828 '<div style="position: relative">' + // Set to the height of the text, causes scrolling
2929 '<div style="position: relative">' + // Moved around its parent to cover visible view
3030 '<div class="CodeMirror-gutter"><div class="CodeMirror-gutter-text"></div></div>' +
@@ -41,6 +41,7 @@ var CodeMirror = (function() {
4141 mover = code . firstChild , gutter = mover . firstChild , gutterText = gutter . firstChild ,
4242 lineSpace = gutter . nextSibling . firstChild , measure = lineSpace . firstChild ,
4343 cursor = measure . nextSibling , lineDiv = cursor . nextSibling ;
44+ themeChanged ( ) ;
4445 // Needed to hide big blue blinking cursor on Mobile Safari
4546 if ( / A p p l e W e b K i t / . test ( navigator . userAgent ) && / M o b i l e \/ \w + / . test ( navigator . userAgent ) ) input . style . width = "0px" ;
4647 if ( ! webkit ) lineSpace . draggable = true ;
@@ -140,7 +141,7 @@ var CodeMirror = (function() {
140141 options [ option ] = value ;
141142 if ( option == "mode" || option == "indentUnit" ) loadMode ( ) ;
142143 else if ( option == "readOnly" && value ) { onBlur ( ) ; input . blur ( ) ; }
143- else if ( option == "theme" ) scroller . className = scroller . className . replace ( / c m - s - \w + / , "cm-s-" + value ) ;
144+ else if ( option == "theme" ) themeChanged ( ) ;
144145 else if ( option == "lineWrapping" && oldVal != value ) operation ( wrappingChanged ) ( ) ;
145146 else if ( option == "tabSize" ) operation ( tabsChanged ) ( ) ;
146147 if ( option == "lineNumbers" || option == "gutter" || option == "firstLineNumber" || option == "theme" )
@@ -1188,6 +1189,10 @@ var CodeMirror = (function() {
11881189 tabText = computeTabText ( ) ;
11891190 updateDisplay ( true ) ;
11901191 }
1192+ function themeChanged ( ) {
1193+ scroller . className = scroller . className . replace ( / \s * c m - s - \w + / g, "" ) +
1194+ options . theme . replace ( / ( ^ | \s ) \s * / g, " cm-s-" ) ;
1195+ }
11911196
11921197 function TextMarker ( ) { this . set = [ ] ; }
11931198 TextMarker . prototype . clear = operation ( function ( ) {
0 commit comments