1import{Component}from '@theme/component';class ProductTitle extends Component{constructor(){super()} 2connectedCallback(){super.connectedCallback();this.#initializeTruncation()} 3#initializeTruncation(){if('ResizeObserver' in window){this.resizeObserver=new ResizeObserver(()=>{this.#calculateTruncation()});this.resizeObserver.observe(this);this.#calculateTruncation()}else{(window).addEventListener('resize',this.#handleResize.bind(this));this.#calculateTruncation()}} 4#calculateTruncation(){const textElement=this.refs.text||this.querySelector('.title-text')||this;if(!textElement.textContent)return;const containerHeight=this.clientHeight;const computedStyle=window.getComputedStyle(this);const lineHeight=parseFloat(computedStyle.lineHeight);const paddingTop=parseFloat(computedStyle.paddingTop);const paddingBottom=parseFloat(computedStyle.paddingBottom);const availableHeight=containerHeight-paddingTop-paddingBottom;const maxLines=Math.max(1,Math.floor(availableHeight/lineHeight));textElement.style.display='-webkit-box';textElement.style.webkitBoxOrient='vertical';textElement.style.overflow='hidden';textElement.style.textOverflow='ellipsis';textElement.style.webkitLineClamp=String(maxLines)} 5#handleResize(){this.#calculateTruncation()} 6disconnectedCallback(){super.disconnectedCallback();if(this.resizeObserver){this.resizeObserver.disconnect()} 7window.removeEventListener('resize',this.#handleResize)}} 8if(!customElements.get('product-title')){customElements.define('product-title',ProductTitle)} 9export default ProductTitle
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.