10201el['on' + eventName]();10202}10203}1020410205/**10206* Данные о товаре10207*10208* @typedef {Object} ProductData10209* @property {string} name - Имя10210* @property {string} price - Цена10211* @property {string} uid - Уникальный идентификатор10212* @property {number|string} inv - Количество
* @property {string} [img] - URL изображения * @property {string} [sku] - * @property {ProductDataOptions[]} [options] - варианты товара *//** * Собирает данные о товаре из элемента DOM * * @param {HTMLElement} productElement - Элемент товара, содержащий данные * @returns {ProductData} Собранные данные о товаре */function t_catalog__collectProductDataByElement(productElement) { // имя var elementName = productElement.querySelector('.js-product-name'); // TODO ST-2949_3: null / undefined (TS18047, TS18048, TS2531, TS2722, TS2454, TS2538) // @ts-expect-error ST-2949_3 var name = elementName ? elementName.textContent.trim() : ''; name = t_catalog_escapeQuote(name); // цена var price; var elementPrice = productElement.querySelector('.js-product-price'); if (elementPrice) { price = elementPrice.getAttribute('data-product-price-def'); } // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046) // @ts-expect-error ST-2949_5 price = t_catalog__cleanPrice(price); // изображение товара var img; // в атрибуте лежит актуальная ссылка на изображение варианта товара var dataImg = productElement.getAttribute('data-product-img'); if (dataImg) { img = dataImg; } else { // иначе ищем элемент с изображением var imgElement = productElement.querySelector('.js-product-img'); if (imgElement) { var original = imgElement.getAttribute('data-original'); if (original) { img = original; } } } // uid var uid = productElement.getAttribute('data-product-uid'); // количество // пустое значение означает бесконечное количество var inv = productElement.getAttribute('data-product-inv'); // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046) // @ts-expect-error ST-2949_5 inv = parseInt(inv, 10) || ''; // stock keeping unit var sku; var skuElement = productElement.querySelector('.js-product-sku, .js-catalog-prod-sku'); if (skuElement) { // TODO ST-2949_3: null / undefined (TS18047, TS18048, TS2531, TS2722, TS2454, TS2538) // @ts-expect-error ST-2949_3 sku = skuElement.textContent.trim(); sku = t_catalog_escapeQuote(sku); } // варианты товара var options = t_catalog__collectOptionsByElement(productElement); // объект для возврата из функции var productData = { name: name, price: price, uid: uid, inv: inv, }; // поля которые могут отсутствовать // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015) // @ts-expect-error ST-2949_2 if (img) productData['img'] = img; // @ts-expect-error ST-2949_2 if (sku) productData['sku'] = sku; // @ts-expect-error ST-2949_2 if (options && options.length > 0) productData['options'] = options; // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046) // @ts-expect-error ST-2949_5