1class FLElement extends HTMLElement { 2 3 /** 4 * Property to store a template element 5 */ 6 template = null 7 8 /** 9 * Function to unbind event listeners. Meant to be replaced by returning a function from bindEvents(). 10 */ 11 unbindEventsCallback = () => {} 12 13 /** 14 * A collection of defaults for localized strings to be merged with the strings attribute. 15 */ 16 defaultStrings = {} 17 18 /** 19 * Array of attributes to watch for changes 20 * 21 * @return Array 22 */ 23 static get observedAttributes() { 24 return [ 'strings' ] 25 } 26 27 /* 28 * Sets up a template element for use later. 29 * 30 * @return void 31 */ 32 constructor() { 33 super() 34 this.template = document.createElement( 'template' ) 35 } 36 37 /** 38 * This is a stub to be overridden in subclasses 39 * 40 * @return Function 41 */ 42 bindEvents() { 43 return this.unbindEventsCallback 44 } 45 46 /** 47 * Override to assign unbind callback 48 */ 49 connectedCallback() { 50 51 /** 52 * To enable a cleanup callback in bindEvents() 53 * you need to assign it when the element is connected to the DOM. 54 * This allows you to return a function from bindEvents() that will 55 * be called on disconnect. Use it to remove any event listeners you added. 56 */ 57 this.unbindEventsCallback = this.bindEvents() 58 } 59 60 /** 61 * Fires when element is disconnected from DOM 62 * 63 * @return void 64 */ 65 disconnectedCallback() { 66 if ( 'function' === typeof this.unbindEventsCallback ) { 67 this.unbindEventsCallback() 68 } 69 } 70 71 /** 72 * Getter for strings property. Merges defaults with strings attribute 73 * 74 * @return Object 75 */ 76 get strings() { 77 return { 78 ...this.defaultStrings, 79 ...JSON.parse( this.getAttribute( 'strings' ) ) 80 } 81 } 82}
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.