Skip to content

Commit

Permalink
15a28f0db351b32b446a20ab2d4accd6acbd9716 Fix: -init layout's output…
Browse files Browse the repository at this point in the history
… depended for a row depended on the order `Start` and `End` were given in. That is no longer the case and `Start` will always preceed `End` in the DOM.

DD-3019

Sync to source repo @15a28f0db351b32b446a20ab2d4accd6acbd9716
  • Loading branch information
dtbuild committed Jan 4, 2025
1 parent cec3813 commit 36d4c8c
Show file tree
Hide file tree
Showing 5 changed files with 55 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.1.8",
"last-sync": "4f47939f6ee3fc533887ec775f202fd833645548"
"last-sync": "15a28f0db351b32b446a20ab2d4accd6acbd9716"
}
28 changes: 26 additions & 2 deletions js/dataTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -13062,7 +13062,7 @@
.addClass(items.className || classes.row)
.appendTo( container );

$.each( items, function (key, val) {
DataTable.ext.renderer.layout._forLayoutRow(items, function (key, val) {
if (key === 'id' || key === 'className') {
return;
}
Expand Down Expand Up @@ -13093,7 +13093,31 @@
})
.append( val.contents )
.appendTo( row );
} );
});
},

// Shared for use by the styling frameworks
_forLayoutRow: function (items, fn) {
// As we are inserting dom elements, we need start / end in a
// specific order, this function is used for sorting the layout
// keys.
var layoutEnum = function (x) {
switch (x) {
case '': return 0;
case 'start': return 1;
case 'end': return 2;
default: return 3;
}
};

Object
.keys(items)
.sort(function (a, b) {
return layoutEnum(a) - layoutEnum(b);
})
.forEach(function (key) {
fn(key, items[key]);
});
}
}
} );
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.

28 changes: 26 additions & 2 deletions js/dataTables.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13009,7 +13009,7 @@ $.extend( true, DataTable.ext.renderer, {
.addClass(items.className || classes.row)
.appendTo( container );

$.each( items, function (key, val) {
DataTable.ext.renderer.layout._forLayoutRow(items, function (key, val) {
if (key === 'id' || key === 'className') {
return;
}
Expand Down Expand Up @@ -13040,7 +13040,31 @@ $.extend( true, DataTable.ext.renderer, {
})
.append( val.contents )
.appendTo( row );
} );
});
},

// Shared for use by the styling frameworks
_forLayoutRow: function (items, fn) {
// As we are inserting dom elements, we need start / end in a
// specific order, this function is used for sorting the layout
// keys.
var layoutEnum = function (x) {
switch (x) {
case '': return 0;
case 'start': return 1;
case 'end': return 2;
default: return 3;
}
};

Object
.keys(items)
.sort(function (a, b) {
return layoutEnum(a) - layoutEnum(b);
})
.forEach(function (key) {
fn(key, items[key]);
});
}
}
} );
Expand Down

0 comments on commit 36d4c8c

Please sign in to comment.