Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
formatLabel(data: IRenderData): h.Child {
// Fetch the label text and mnemonic index.
let { label, mnemonic } = data.item;
// If the index is out of range, do not modify the label.
if (mnemonic < 0 || mnemonic >= label.length) {
return label;
}
// Split the label into parts.
let prefix = label.slice(0, mnemonic);
let suffix = label.slice(mnemonic + 1);
let char = label[mnemonic];
// Wrap the mnemonic character in a span.
let span = h.span({ className: 'p-Menu-itemMnemonic' }, char);
// Return the content parts.
return [prefix, span, suffix];
}
formatLabel(data: IRenderData): h.Child {
// Fetch the label text and mnemonic index.
let { label, mnemonic } = data.title;
// If the index is out of range, do not modify the label.
if (mnemonic < 0 || mnemonic >= label.length) {
return label;
}
// Split the label into parts.
let prefix = label.slice(0, mnemonic);
let suffix = label.slice(mnemonic + 1);
let char = label[mnemonic];
// Wrap the mnemonic character in a span.
let span = h.span({ className: 'p-MenuBar-itemMnemonic' }, char);
// Return the content parts.
return [prefix, span, suffix];
}
}