1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-11-30 12:24:10 +01:00

Fix: If there was a nested table in the thead of our target table, then the getElementsByTagName was getting the wrong element - so use a more specific jQuery selector.

This commit is contained in:
Allan Jardine 2011-05-19 18:58:32 +01:00
parent 55c4e0ac9c
commit 2eacc63f87

View File

@ -7245,23 +7245,28 @@
/*
* Final init
* Sanity check that there is a thead and tbody. If not let's just create them
* Cache the header, body and footer as required, creating them if needed
*/
if ( this.getElementsByTagName('thead').length === 0 )
var thead = $('>thead', this);
if ( thead.length === 0 )
{
this.appendChild( document.createElement( 'thead' ) );
thead = [ document.createElement( 'thead' ) ];
this.appendChild( thead[0] );
}
oSettings.nTHead = thead[0];
if ( this.getElementsByTagName('tbody').length === 0 )
var tbody = $('>tbody', this);
if ( tbody.length === 0 )
{
this.appendChild( document.createElement( 'tbody' ) );
tbody = [ document.createElement( 'tbody' ) ];
this.appendChild( tbody[0] );
}
oSettings.nTBody = tbody[0];
oSettings.nTHead = this.getElementsByTagName('thead')[0];
oSettings.nTBody = this.getElementsByTagName('tbody')[0];
if ( this.getElementsByTagName('tfoot').length > 0 )
var tfoot = $('>tfoot', this);
if ( tfoot.length > 0 )
{
oSettings.nTFoot = this.getElementsByTagName('tfoot')[0];
oSettings.nTFoot = tfoot[0];
_fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
}