mirror of
https://github.com/flarum/framework.git
synced 2025-05-23 23:29:57 +08:00
Replace Ember app with Mithril app
This commit is contained in:
21
js/lib/helpers/list-items.js
Normal file
21
js/lib/helpers/list-items.js
Normal file
@ -0,0 +1,21 @@
|
||||
import Separator from 'flarum/components/separator';
|
||||
|
||||
function isSeparator(item) {
|
||||
return item && item.component === Separator;
|
||||
}
|
||||
|
||||
export default function listItems(array, noWrap) {
|
||||
// Remove duplicate/unnecessary separators
|
||||
var prevItem;
|
||||
var newArray = [];
|
||||
array.forEach(function(item, i) {
|
||||
if ((!prevItem || isSeparator(prevItem) || i === array.length - 1) && isSeparator(item)) {
|
||||
|
||||
} else {
|
||||
prevItem = item;
|
||||
newArray.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
return newArray.map(item => [(noWrap && !isSeparator(item)) ? item : m('li', {className: (item.props && item.props.wrapperClass) || (item.component && item.component.wrapperClass) || ''}, item), ' ']);
|
||||
};
|
Reference in New Issue
Block a user