Skip to content

Commit

Permalink
fix: remove bug in addWitnesses() when target is the only child element
Browse files Browse the repository at this point in the history
  • Loading branch information
malkja committed Oct 18, 2024
1 parent 1943dc4 commit e194ffc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utils/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,17 @@ export function addWitness(target, witness, color) {
if (targetIndex < 0) return;

const witnessEl = createWitnessEl(witness, color)
const isWrapper = parentEl.children[targetIndex-1].classList.contains("witnesses")

let isWrapper = false
if (parentEl.children.length === 1) {
// target is the only child element
isWrapper = false
} else {
isWrapper = parentEl.children[targetIndex-1].classList.contains("witnesses")
}

if (isWrapper) {
let wrapper = parentEl.children[targetIndex-1]
const wrapper = parentEl.children[targetIndex-1]
wrapper.appendChild(witnessEl)
} else {
// witnesses wrapper which holds the witnesses 'chips' is not yet created -> we add the first witness
Expand Down

0 comments on commit e194ffc

Please sign in to comment.