File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ function wtResponsiveTable() {
12
12
var headerIndex = 0 ;
13
13
Array . prototype . forEach . call ( row . querySelectorAll ( 'td' ) , function ( value , index ) {
14
14
var th = value . parentElement . querySelector ( 'th' ) || headers . item ( headerIndex ) ;
15
- var title = th . textContent ;
15
+ var title = th && th . textContent ;
16
16
if ( title && ! value . getAttributeNode ( 'data-title' ) ) {
17
17
value . setAttribute ( 'data-title' , title ) ;
18
18
}
Original file line number Diff line number Diff line change @@ -233,6 +233,34 @@ describe('directive', function () {
233
233
expect ( firstDataRow . eq ( 3 ) . attr ( 'data-title' ) ) . toBe ( 'Forth title' ) ;
234
234
} ) ;
235
235
236
+ it ( 'supports ng-if applied on TD with data-title' , function ( ) {
237
+ var markup = [
238
+ '<table wt-responsive-table>' ,
239
+ ' <thead>' ,
240
+ ' <tr>' ,
241
+ ' <th>column</th>' ,
242
+ ' </tr>' ,
243
+ ' </thead>' ,
244
+ ' <tbody>' ,
245
+ ' <tr>' ,
246
+ ' <td ng-if="!condition">tom</td>' ,
247
+ ' <td ng-if="condition" data-title="column">jerry</td>' ,
248
+ ' </tr>' ,
249
+ ' </tbody>' ,
250
+ '</table>'
251
+ ] . join ( '' ) ;
252
+ var element = angular . element ( markup ) ;
253
+ var scope = $rootScope . $new ( ) ;
254
+ scope . condition = true ;
255
+
256
+ var firstDataRow = element . find ( 'tbody tr:first td' ) ;
257
+
258
+ $compile ( element ) ( scope ) ;
259
+
260
+ expect ( firstDataRow . eq ( 1 ) . text ( ) ) . toBe ( 'jerry' ) ;
261
+ expect ( firstDataRow . eq ( 1 ) . attr ( 'data-title' ) ) . toBe ( 'column' ) ;
262
+ } ) ;
263
+
236
264
it ( 'supports bootstrap' , function ( ) {
237
265
var markup = [
238
266
'<table wt-responsive-table class="table" style="display: none;">' ,
You can’t perform that action at this time.
0 commit comments