1import { Controller } from "../stimulus.js"; 2 3const MIN_IMAGE_SIZE = 16; 4 5export default class extends Controller { 6 static targets = ["image", "fallback"] 7 8 connect() { 9 this.handleLoad = this.handleLoad.bind(this); 10 this.imageTarget.addEventListener("load", this.handleLoad); 11 if (this.imageTarget.complete) { 12 this.handleLoad(); 13 } 14 } 15 16 disconnect() { 17 this.imageTarget.removeEventListener("load", this.handleLoad); 18 } 19 20 handleLoad() { 21 const { naturalWidth, naturalHeight } = this.imageTarget; 22 if (naturalWidth >= MIN_IMAGE_SIZE && naturalHeight >= MIN_IMAGE_SIZE) { 23 this.imageTarget.hidden = false; 24 this.fallbackTarget.hidden = true; 25 } 26 } 27}
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.