diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 4bfaf8d6..6fb37ac7 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -2970,11 +2970,20 @@ nScrollFootTable.style.marginLeft = "0"; } - /* Move any caption elements from the body to the header */ - var nCaptions = $(oSettings.nTable).children('caption'); - for ( var i=0, iLen=nCaptions.length ; i 0 ) { - nScrollHeadTable.appendChild( nCaptions[i] ); + nCaption = nCaption[0]; + if ( nCaption._captionSide === "top" ) + { + nScrollHeadTable.appendChild( nCaption ); + } + else if ( nCaption._captionSide === "bottom" && nTfoot ) + { + nScrollFootTable.appendChild( nCaption ); + } } /* @@ -6508,6 +6517,12 @@ * Final init * Cache the header, body and footer as required, creating them if needed */ + + // Work around for Webkit bug 83867 - store the caption-side before removing from doc + var captions = $(this).children('caption').each( function () { + this._captionSide = $(this).css('caption-side'); + } ); + var thead = $(this).children('thead'); if ( thead.length === 0 ) { @@ -6528,6 +6543,14 @@ oSettings.nTBody.setAttribute( "aria-relevant", "all" ); var tfoot = $(this).children('tfoot'); + if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") ) + { + // If we are a scrolling table, and no footer has been given, then we need to create + // a tfoot element for the caption element to be appended to + tfoot = [ document.createElement( 'tfoot' ) ]; + this.appendChild( tfoot[0] ); + } + if ( tfoot.length > 0 ) { oSettings.nTFoot = tfoot[0]; diff --git a/media/src/core/core.constructor.js b/media/src/core/core.constructor.js index 10e47e97..ed0756d9 100644 --- a/media/src/core/core.constructor.js +++ b/media/src/core/core.constructor.js @@ -370,6 +370,12 @@ _fnSortingClasses( oSettings ); * Final init * Cache the header, body and footer as required, creating them if needed */ + +// Work around for Webkit bug 83867 - store the caption-side before removing from doc +var captions = $(this).children('caption').each( function () { + this._captionSide = $(this).css('caption-side'); +} ); + var thead = $(this).children('thead'); if ( thead.length === 0 ) { @@ -390,6 +396,14 @@ oSettings.nTBody.setAttribute( "aria-live", "polite" ); oSettings.nTBody.setAttribute( "aria-relevant", "all" ); var tfoot = $(this).children('tfoot'); +if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") ) +{ + // If we are a scrolling table, and no footer has been given, then we need to create + // a tfoot element for the caption element to be appended to + tfoot = [ document.createElement( 'tfoot' ) ]; + this.appendChild( tfoot[0] ); +} + if ( tfoot.length > 0 ) { oSettings.nTFoot = tfoot[0]; diff --git a/media/src/core/core.scrolling.js b/media/src/core/core.scrolling.js index 429888c9..1889fd9f 100644 --- a/media/src/core/core.scrolling.js +++ b/media/src/core/core.scrolling.js @@ -89,11 +89,20 @@ function _fnFeatureHtmlTable ( oSettings ) nScrollFootTable.style.marginLeft = "0"; } - /* Move any caption elements from the body to the header */ - var nCaptions = $(oSettings.nTable).children('caption'); - for ( var i=0, iLen=nCaptions.length ; i 0 ) { - nScrollHeadTable.appendChild( nCaptions[i] ); + nCaption = nCaption[0]; + if ( nCaption._captionSide === "top" ) + { + nScrollHeadTable.appendChild( nCaption ); + } + else if ( nCaption._captionSide === "bottom" && nTfoot ) + { + nScrollFootTable.appendChild( nCaption ); + } } /*