File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -122,9 +122,8 @@ proto.createButton = function (config) {
122122 button . className = 'modebar-btn' ;
123123
124124 var title = config . title ;
125- if ( title !== null && title !== false && title !== '' ) {
126- button . setAttribute ( 'data-title' , title || config . name ) ;
127- }
125+ if ( title === undefined ) title = config . name ;
126+ if ( title || title === 0 ) button . setAttribute ( 'data-title' , title ) ;
128127
129128 if ( config . attr !== undefined ) button . setAttribute ( 'data-attr' , config . attr ) ;
130129
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ describe('ModeBar', function() {
101101 expect ( checkBtnAttr ( modeBar , 0 , 'data-title' ) ) . toEqual ( 'the title too' ) ;
102102 } ) ;
103103
104- it ( 'hides title to when title is set to null or \'\' or false ' , function ( ) {
104+ it ( 'hides title to when title is falsy but not 0 ' , function ( ) {
105105 var modeBar ;
106106
107107 modeBar = createModeBar ( getMockGraphInfo ( ) , [ [
@@ -118,6 +118,11 @@ describe('ModeBar', function() {
118118 { name : 'button' , title : false , click : noop }
119119 ] ] ) ;
120120 expect ( checkBtnAttr ( modeBar , 0 , 'data-title' ) ) . toBe ( null ) ;
121+
122+ modeBar = createModeBar ( getMockGraphInfo ( ) , [ [
123+ { name : 'button' , title : 0 , click : noop }
124+ ] ] ) ;
125+ expect ( checkBtnAttr ( modeBar , 0 , 'data-title' ) ) . toEqual ( '0' ) ;
121126 } ) ;
122127 } ) ;
123128
You can’t perform that action at this time.
0 commit comments