Web Dev Solutions

Catalin Mititiuc

From 7021b499339ae1e9bede4fe85895108c49b805a4 Mon Sep 17 00:00:00 2001 From: Catalin Mititiuc Date: Wed, 15 May 2024 11:23:21 -0700 Subject: Don't blow up if weapon element missing from trooper counters --- src/modules/record_sheet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/record_sheet.js b/src/modules/record_sheet.js index 4d8aada..78dbace 100644 --- a/src/modules/record_sheet.js +++ b/src/modules/record_sheet.js @@ -41,7 +41,7 @@ function createIcon(number) { function createRecord(unit) { const { dataset: { allegiance, number }} = unit, primaryWeapon = unit.querySelector('.primary-weapon'), - pw = primaryWeapon.getAttribute('href').replace('#', ''), + pw = primaryWeapon?.getAttribute('href').replace('#', '') || 'rifle', div = document.createElement('div', { is: 'soldier-record-block' }), spans = Array(5).fill('span').map(t => document.createElement(t)), [tn, pwt, pwd, pwrs, pwrl] = spans; -- cgit v1.2.3