Skip to content

Commit

Permalink
[JENKINS-48773] - Limit which section headers are added to the breadc…
Browse files Browse the repository at this point in the history
…rumb config outline (#3213)

* [JENKINS-48773] Don't include section elements in repeatables

* Only include visible section headers

* Fix tests by checking for presence of method first
  • Loading branch information
daniel-beck authored and oleg-nenashev committed Jan 11, 2018
1 parent deeab3a commit 02d0531
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions core/src/main/resources/lib/form/section_.js
Expand Up @@ -38,21 +38,27 @@ var section = (function (){
root = $(root||document.body);

/**
* Recursively visit elements and find all section headers.
* Recursively visit elements and find all visible section headers that are not inside f:repeatable elements.
*
* @param {HTMLElement} dom
* Parent element
* @param {SectionNode} parent
* Function that returns the array to which discovered section headers and child elements are added.
*/
function visitor(dom,parent) {
function isVisible(elem) {
return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects && elem.getClientRects().length );
}

for (var e=dom.firstChild; e!=null; e=e.nextSibling) {
if (e.nodeType==1) {
if (e.className=="section-header") {
if (e.className=="section-header" && isVisible(e)) {
var child = new SectionNode(e);
parent.children.push(child);
// The next line seems to be unnecessary, as there are no children inside the section header itself.
// So this code will always returns a flat list of section headers.
visitor(e,child);
} else {
} else if (!e.classList.contains("repeated-container")) {
visitor(e,parent);
}
}
Expand Down

0 comments on commit 02d0531

Please sign in to comment.