Skip to content

Commit e900b62

Browse files
committed
[Yash] revert to code before semgrep fix
1 parent 33ce6f8 commit e900b62

File tree

2 files changed

+22
-31
lines changed

2 files changed

+22
-31
lines changed

src/graphing/components/quadrants.js

+21-30
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,6 @@ let prevLeft, prevTop
1919
let quadrantScrollHandlerReference
2020
let scrollFlag = false
2121

22-
const createElement = (tagName, text, attributes) => {
23-
const tag = document.createElement(tagName)
24-
Object.keys(attributes).forEach((keyName) => {
25-
tag.setAttribute(keyName, attributes[keyName])
26-
})
27-
tag.appendChild(document.createTextNode(text))
28-
return tag
29-
}
30-
31-
const replaceChild = (element, child) => {
32-
let elementChild = element.lastElementChild
33-
while (elementChild) {
34-
element.removeChild(elementChild)
35-
elementChild = element.lastElementChild
36-
}
37-
element.appendChild(child)
38-
}
39-
4022
function selectRadarQuadrant(order, startAngle, name) {
4123
const noOfBlips = d3.selectAll('.quadrant-group-' + order + ' .blip-link').size()
4224
d3.select('#radar').classed('no-blips', noOfBlips === 0)
@@ -217,19 +199,19 @@ function wrapQuadrantNameInMultiLine(elem, isTopQuadrants, quadrantNameGroup, ti
217199
const words = text.split(' ')
218200
let line = ''
219201

220-
replaceChild(element, createElement('tspan', text, { id: 'text-width-check' }))
202+
element.innerHTML = `<tspan id="text-width-check">${text}</tspan >`
221203
const testElem = document.getElementById('text-width-check')
222204

223205
function maxCharactersToFit(testLine, suffix) {
224206
let j = 1
225207
let firstLineWidth = 0
226208
const testElem1 = document.getElementById('text-width-check')
227-
testElem1.textContent = testLine
209+
testElem1.innerHTML = testLine
228210
if (testElem1.getBoundingClientRect().width < maxWidth) {
229211
return testLine.length
230212
}
231213
while (firstLineWidth < maxWidth && testLine.length > j) {
232-
testElem1.textContent = testLine.substring(0, j) + suffix
214+
testElem1.innerHTML = testLine.substring(0, j) + suffix
233215
firstLineWidth = testElem1.getBoundingClientRect().width
234216

235217
j++
@@ -250,33 +232,42 @@ function wrapQuadrantNameInMultiLine(elem, isTopQuadrants, quadrantNameGroup, ti
250232
if (testElem.getBoundingClientRect().width > maxWidth) {
251233
for (let i = 0; i < words.length; i++) {
252234
let testLine = line + words[i] + ' '
253-
testElem.textContent = testLine
235+
testElem.innerHTML = testLine
254236
const textWidth = testElem.getBoundingClientRect().width
255237

256238
if (textWidth > maxWidth) {
257239
if (i === 0) {
258240
let lineBreakIndex = maxCharactersToFit(testLine, '-')
259-
const elementText = `${words[i].substring(0, lineBreakIndex)}-`
260-
element.appendChild(createElement('tspan', elementText, { x: '0', dy }))
241+
element.innerHTML += '<tspan x="0" dy="' + dy + '">' + words[i].substring(0, lineBreakIndex) + '-</tspan>'
261242
const secondLine = words[i].substring(lineBreakIndex, words[i].length) + ' ' + words.slice(i + 1).join(' ')
262243
lineBreakIndex = maxCharactersToFit(secondLine, '...')
263-
const text = `${secondLine.substring(0, lineBreakIndex)}${ellipsis(lineBreakIndex, secondLine)}`
264-
element.appendChild(createElement('tspan', text, { x: '0', dy: '20' }))
244+
element.innerHTML +=
245+
'<tspan x="0" dy="' +
246+
20 +
247+
'">' +
248+
secondLine.substring(0, lineBreakIndex) +
249+
ellipsis(lineBreakIndex, secondLine) +
250+
'</tspan>'
265251
break
266252
} else {
267-
element.appendChild(createElement('tspan', line, { x: '0', dy }))
253+
element.innerHTML += '<tspan x="0" dy="' + dy + '">' + line + '</tspan>'
268254
const secondLine = words.slice(i).join(' ')
269255
const lineBreakIndex = maxCharactersToFit(secondLine, '...')
270-
const text = `${secondLine.substring(0, lineBreakIndex)}${ellipsis(lineBreakIndex, secondLine)}`
271-
element.appendChild(createElement('tspan', text, { x: '0', dy: '20' }))
256+
element.innerHTML +=
257+
'<tspan x="0" dy="' +
258+
20 +
259+
'">' +
260+
secondLine.substring(0, lineBreakIndex) +
261+
ellipsis(lineBreakIndex, secondLine) +
262+
'</tspan>'
272263
}
273264
line = words[i] + ' '
274265
} else {
275266
line = testLine
276267
}
277268
}
278269
} else {
279-
element.appendChild(createElement('tspan', text, { x: '0' }))
270+
element.innerHTML += '<tspan x="0">' + text + '</tspan>'
280271
}
281272

282273
document.getElementById('text-width-check').remove()

src/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<link href="/images/favicon.ico" rel="icon" />
77
<link rel="preconnect" href="https://rsms.me/" />
8-
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" integrity="sha512-byor" />
8+
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" integrity="sha512-byor" crossorigin="anonymous" />
99
<link rel="preconnect" href="https://fonts.googleapis.com" />
1010
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1111
<link href="https://fonts.googleapis.com/css2?family=Bitter:wght@700&display=swap" rel="stylesheet" />

0 commit comments

Comments
 (0)