1import { Controller } from "@hotwired/stimulus" 2 3export default class extends Controller { 4 static targets = ['target', 'template'] 5 static values = { 6 wrapperSelector: String 7 } 8 9 initialize () { 10 this.wrapperSelector = this.wrapperSelectorValue || '.nested-form-wrapper' 11 } 12 13 add (event) { 14 event.preventDefault() 15 16 const content = this.templateTarget.innerHTML.replace(/NEW_RECORD/g, new Date().getTime()) 17 this.targetTarget.insertAdjacentHTML('beforebegin', content) 18 } 19 20 remove (event) { 21 event.preventDefault() 22 23 const wrapper = event.target.closest(this.wrapperSelector) 24 25 if (wrapper.dataset.newRecord === 'true') { 26 wrapper.remove() 27 } else { 28 wrapper.style.display = 'none' 29 wrapper.querySelector("input[name*='_destroy']").value = 1 30 } 31 } 32};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.