Skip to content

Commit

Permalink
1d5373e1276fa1ffe755d054027ca3acfb23f0e5 Fix: Using a <span> in `-i…
Browse files Browse the repository at this point in the history
…nit language.lengthMenu` could result in duplication of the page length `<select>` tag.

DD-2981
https://datatables.net/forums/discussion/79286

Sync to source repo @1d5373e1276fa1ffe755d054027ca3acfb23f0e5
  • Loading branch information
dtbuild committed Jul 10, 2024
1 parent 1c8578c commit f79aed7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion datatables.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
],
"src-repo": "http://github.com/DataTables/DataTablesSrc",
"last-tag": "2.0.8",
"last-sync": "a8e62f88683146e4bad8b9550c85c772795a007a"
"last-sync": "1d5373e1276fa1ffe755d054027ca3acfb23f0e5"
}
5 changes: 3 additions & 2 deletions js/dataTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -13391,10 +13391,11 @@
}

// Wrapper element - use a span as a holder for where the select will go
var tmpId = 'tmp-' + (+new Date())
var div = $('<div/>')
.addClass( classes.container )
.append(
str.replace( '_MENU_', '<span></span>' )
str.replace( '_MENU_', '<span id="'+tmpId+'"></span>' )
);

// Save text node content for macro updating
Expand Down Expand Up @@ -13437,7 +13438,7 @@
__lengthCounter++;

// Swap in the select list
div.find('span').replaceWith(select);
div.find('#' + tmpId).replaceWith(select);

// Can't use `select` variable as user might provide their own and the
// reference is broken by the use of outerHTML
Expand Down
2 changes: 1 addition & 1 deletion js/dataTables.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dataTables.min.mjs

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions js/dataTables.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13338,10 +13338,11 @@ DataTable.feature.register( 'pageLength', function ( settings, opts ) {
}

// Wrapper element - use a span as a holder for where the select will go
var tmpId = 'tmp-' + (+new Date())
var div = $('<div/>')
.addClass( classes.container )
.append(
str.replace( '_MENU_', '<span></span>' )
str.replace( '_MENU_', '<span id="'+tmpId+'"></span>' )
);

// Save text node content for macro updating
Expand Down Expand Up @@ -13384,7 +13385,7 @@ DataTable.feature.register( 'pageLength', function ( settings, opts ) {
__lengthCounter++;

// Swap in the select list
div.find('span').replaceWith(select);
div.find('#' + tmpId).replaceWith(select);

// Can't use `select` variable as user might provide their own and the
// reference is broken by the use of outerHTML
Expand Down

0 comments on commit f79aed7

Please sign in to comment.