4040module . exports = classNames ;
4141} else if ( typeof define === 'function' && typeof define . amd === 'object' && define . amd ) {
4242// register as 'classnames', consistent with npm package name
43- define ( 'classnames' , function ( ) {
43+ define ( 'classnames' , [ ] , function ( ) {
4444return classNames ;
4545} ) ;
4646} else {
461461if ( horiz . clientWidth ) scroll ( horiz . scrollLeft , "horizontal" ) ;
462462} ) ;
463463
464- this . checkedOverlay = false ;
464+ this . checkedZeroWidth = false ;
465465// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
466466if ( ie && ie_version < 8 ) this . horiz . style . minHeight = this . vert . style . minWidth = "18px" ;
467467}
496496this . horiz . firstChild . style . width = "0" ;
497497}
498498
499- if ( ! this . checkedOverlay && measure . clientHeight > 0 ) {
500- if ( sWidth == 0 ) this . overlayHack ( ) ;
501- this . checkedOverlay = true ;
499+ if ( ! this . checkedZeroWidth && measure . clientHeight > 0 ) {
500+ if ( sWidth == 0 ) this . zeroWidthHack ( ) ;
501+ this . checkedZeroWidth = true ;
502502}
503503
504504return { right : needsV ? sWidth : 0 , bottom : needsH ? sWidth : 0 } ;
505505} ,
506506setScrollLeft : function ( pos ) {
507507if ( this . horiz . scrollLeft != pos ) this . horiz . scrollLeft = pos ;
508+ if ( this . disableHoriz ) this . enableZeroWidthBar ( this . horiz , this . disableHoriz ) ;
508509} ,
509510setScrollTop : function ( pos ) {
510511if ( this . vert . scrollTop != pos ) this . vert . scrollTop = pos ;
512+ if ( this . disableVert ) this . enableZeroWidthBar ( this . vert , this . disableVert ) ;
511513} ,
512- overlayHack : function ( ) {
514+ zeroWidthHack : function ( ) {
513515var w = mac && ! mac_geMountainLion ? "12px" : "18px" ;
514- this . horiz . style . minHeight = this . vert . style . minWidth = w ;
515- var self = this ;
516- var barMouseDown = function ( e ) {
517- if ( e_target ( e ) != self . vert && e_target ( e ) != self . horiz )
518- operation ( self . cm , onMouseDown ) ( e ) ;
519- } ;
520- on ( this . vert , "mousedown" , barMouseDown ) ;
521- on ( this . horiz , "mousedown" , barMouseDown ) ;
516+ this . horiz . style . height = this . vert . style . width = w ;
517+ this . horiz . style . pointerEvents = this . vert . style . pointerEvents = "none" ;
518+ this . disableHoriz = new Delayed ;
519+ this . disableVert = new Delayed ;
520+ } ,
521+ enableZeroWidthBar : function ( bar , delay ) {
522+ bar . style . pointerEvents = "auto" ;
523+ function maybeDisable ( ) {
524+ // To find out whether the scrollbar is still visible, we
525+ // check whether the element under the pixel in the bottom
526+ // left corner of the scrollbar box is the scrollbar box
527+ // itself (when the bar is still visible) or its filler child
528+ // (when the bar is hidden). If it is still visible, we keep
529+ // it enabled, if it's hidden, we disable pointer events.
530+ var box = bar . getBoundingClientRect ( ) ;
531+ var elt = document . elementFromPoint ( box . left + 1 , box . bottom - 1 ) ;
532+ if ( elt != bar ) bar . style . pointerEvents = "none" ;
533+ else delay . set ( 1000 , maybeDisable ) ;
534+ }
535+ delay . set ( 1000 , maybeDisable ) ;
522536} ,
523537clear : function ( ) {
524538var parent = this . horiz . parentNode ;
31443158
31453159if ( cm . state . focused && op . updateInput )
31463160cm . display . input . reset ( op . typing ) ;
3147- if ( op . focus && op . focus == activeElt ( ) ) ensureFocus ( op . cm ) ;
3161+ if ( op . focus && op . focus == activeElt ( ) && ( ! document . hasFocus || document . hasFocus ( ) ) )
3162+ ensureFocus ( op . cm ) ;
31483163}
31493164
31503165function endOperation_finish ( op ) {
38293844
38303845// Determines whether an event happened in the gutter, and fires the
38313846// handlers for the corresponding event.
3832- function gutterEvent ( cm , e , type , prevent , signalfn ) {
3847+ function gutterEvent ( cm , e , type , prevent ) {
38333848try { var mX = e . clientX , mY = e . clientY ; }
38343849catch ( e ) { return false ; }
38353850if ( mX >= Math . floor ( cm . display . gutters . getBoundingClientRect ( ) . right ) ) return false ;
38463861if ( g && g . getBoundingClientRect ( ) . right >= mX ) {
38473862var line = lineAtHeight ( cm . doc , mY ) ;
38483863var gutter = cm . options . gutters [ i ] ;
3849- signalfn ( cm , type , cm , line , gutter , e ) ;
3864+ signal ( cm , type , cm , line , gutter , e ) ;
38503865return e_defaultPrevented ( e ) ;
38513866}
38523867}
38533868}
38543869
38553870function clickInGutter ( cm , e ) {
3856- return gutterEvent ( cm , e , "gutterClick" , true , signalLater ) ;
3871+ return gutterEvent ( cm , e , "gutterClick" , true ) ;
38573872}
38583873
38593874// Kludge to work around strange IE behavior where it'll sometimes
42924307
42934308function contextMenuInGutter ( cm , e ) {
42944309if ( ! hasHandler ( cm , "gutterContextMenu" ) ) return false ;
4295- return gutterEvent ( cm , e , "gutterContextMenu" , false , signal ) ;
4310+ return gutterEvent ( cm , e , "gutterContextMenu" , false ) ;
42964311}
42974312
42984313// UPDATING
71257140spanEndStyle = "" ;
71267141}
71277142if ( m . className ) spanStyle += " " + m . className ;
7128- if ( m . css ) css = m . css ;
7143+ if ( m . css ) css = ( css ? css + ";" : "" ) + m . css ;
71297144if ( m . startStyle && sp . from == pos ) spanStartStyle += " " + m . startStyle ;
71307145if ( m . endStyle && sp . to == nextChange ) spanEndStyle += " " + m . endStyle ;
71317146if ( m . title && ! title ) title = m . title ;
73947409this . id = ++ nextDocId ;
73957410this . modeOption = mode ;
73967411this . lineSep = lineSep ;
7412+ this . extend = false ;
73977413
73987414if ( typeof text == "string" ) text = this . splitLines ( text ) ;
73997415updateDoc ( this , { from : start , to : start , text : text } ) ;
89018917
89028918// THE END
89038919
8904- CodeMirror . version = "5.8 .0" ;
8920+ CodeMirror . version = "5.9 .0" ;
89058921
89068922return CodeMirror ;
89078923} ) ;
@@ -8938,8 +8954,8 @@ var CodeMirror = React.createClass({
89388954this . codeMirror . on ( 'change' , this . codemirrorValueChanged ) ;
89398955this . codeMirror . on ( 'focus' , this . focusChanged . bind ( this , true ) ) ;
89408956this . codeMirror . on ( 'blur' , this . focusChanged . bind ( this , false ) ) ;
8941- this . _currentCodemirrorValue = this . props . value ;
8942- this . codeMirror . setValue ( this . props . value ) ;
8957+ this . _currentCodemirrorValue = this . props . defaultValue || this . props . value || '' ;
8958+ this . codeMirror . setValue ( this . _currentCodemirrorValue ) ;
89438959} ,
89448960
89458961componentWillUnmount : function componentWillUnmount ( ) {
@@ -8950,7 +8966,7 @@ var CodeMirror = React.createClass({
89508966} ,
89518967
89528968componentWillReceiveProps : function componentWillReceiveProps ( nextProps ) {
8953- if ( this . codeMirror && this . _currentCodemirrorValue !== nextProps . value ) {
8969+ if ( this . codeMirror && nextProps . value !== undefined && this . _currentCodemirrorValue !== nextProps . value ) {
89548970this . codeMirror . setValue ( nextProps . value ) ;
89558971}
89568972if ( typeof nextProps . options === 'object' ) {
0 commit comments