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) {
122
122
button . className = 'modebar-btn' ;
123
123
124
124
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 ) ;
128
127
129
128
if ( config . attr !== undefined ) button . setAttribute ( 'data-attr' , config . attr ) ;
130
129
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ describe('ModeBar', function() {
101
101
expect ( checkBtnAttr ( modeBar , 0 , 'data-title' ) ) . toEqual ( 'the title too' ) ;
102
102
} ) ;
103
103
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 ( ) {
105
105
var modeBar ;
106
106
107
107
modeBar = createModeBar ( getMockGraphInfo ( ) , [ [
@@ -118,6 +118,11 @@ describe('ModeBar', function() {
118
118
{ name : 'button' , title : false , click : noop }
119
119
] ] ) ;
120
120
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' ) ;
121
126
} ) ;
122
127
} ) ;
123
128
You can’t perform that action at this time.
0 commit comments