MCPcopy Create free account
hub / github.com/breck7/scroll / toggle

Method toggle

external/.scrollLibs.js:24610–24619  ·  view source on GitHub ↗
(cue, contentOptions)

Source from the content-addressed store, hash-verified

24608 }
24609 // todo: move to keyword particle class?
24610 toggle(cue, contentOptions) {
24611 const currentParticle = this.getParticle(cue)
24612 if (!contentOptions) return currentParticle ? currentParticle.unmountAndDestroy() : this.appendLine(cue)
24613 const currentContent = currentParticle === undefined ? undefined : currentParticle.content
24614 const index = contentOptions.indexOf(currentContent)
24615 const newContent = index === -1 || index + 1 === contentOptions.length ? contentOptions[0] : contentOptions[index + 1]
24616 this.delete(cue)
24617 if (newContent) this.touchParticle(cue).setContent(newContent)
24618 return newContent
24619 }
24620 isMounted() {
24621 return !!this._htmlStumpParticle
24622 }

Callers 1

toggleAndRenderMethod · 0.95

Calls 7

unmountAndDestroyMethod · 0.80
appendLineMethod · 0.80
indexOfMethod · 0.80
setContentMethod · 0.80
touchParticleMethod · 0.80
getParticleMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected