Skip to content
Snippets Groups Projects

Resolve "When the branch name is a divider or separator, the project home page cannot display the branch name correctly."

2 unresolved threads
Compare and Show latest version
1 file
+ 41
41
Compare changes
  • Side-by-side
  • Inline
function escape(text) {
return text ? String(text).replace(/'/g, "\\'") : text;
return text ? String(text).replace(/'/g, "\\'") : text;
}
function ingestOptions(options, group, index) {
const ingested = Object.assign( {}, options, {
const ingested = Object.assign( {}, options, {
'params': {
group,
index
}
});
if(options.renderRow){
ingested.renderRow = options.renderRow.bind(options);
}
if(options.renderRow){
ingested.renderRow = options.renderRow.bind(options);
}
return ingested;
return ingested;
}
function getOptionValue(chunk, options) {
let value;
let value;
if (!options.renderRow) {
value = escape( options.id ? options.id(chunk) : chunk.id );
if (!options.renderRow) {
value = escape( options.id ? options.id(chunk) : chunk.id );
}
return value;
return value;
}
function checkSelected(chunk, options) {
@@ -140,13 +140,13 @@ function generateLink(li, chunk, options) {
function hideRow(li, chunk, options) {
const row = li.cloneNode(true);
const value = getOptionValue(chunk, options);
const value = getOptionValue(chunk, options);
if (options.hideRow && options.hideRow(value)) {
row.style.display = 'none';
}
if (options.hideRow && options.hideRow(value)) {
row.style.display = 'none';
}
return row;
return row;
}
function handleOptions(li, chunk, options) {
@@ -163,37 +163,37 @@ function handleOptions(li, chunk, options) {
}
const specialProcessors = {
'divider': () => {
const row = document.createElement('li');
row.classList.add('divider');
return row;
},
'separator': () => {
const row = document.createElement('li');
row.classList.add('separator');
return row;
},
'header': (chunk) => {
const row = document.createElement('li');
row.classList.add('dropdown-header');
row.innerHTML = chunk.content;
return row;
}
'divider': () => {
const row = document.createElement('li');
row.classList.add('divider');
return row;
},
'separator': () => {
const row = document.createElement('li');
row.classList.add('separator');
return row;
},
'header': (chunk) => {
const row = document.createElement('li');
row.classList.add('dropdown-header');
row.innerHTML = chunk.content;
return row;
}
};
export function item({data: chunk, options = {}, group = false, index = false}) {
const opts = ingestOptions(options, group, index);
let standardRender = true;
let li = document.createElement('li');
let li = document.createElement('li');
if (specialProcessors[chunk.type]) {
if (specialProcessors[chunk.type]) {
li = specialProcessors[chunk.type](chunk);
standardRender = false;
}
@@ -203,7 +203,7 @@ export function item({data: chunk, options = {}, group = false, index = false})
if (standardRender) {
li = handleOptions(li, chunk, opts);
}
return li;
}
Loading