Skip to content

Commit

Permalink
fix(IE11): quash exception [dirty hack]
Browse files Browse the repository at this point in the history
  • Loading branch information
yumetodo committed Nov 11, 2017
1 parent 4ef4a21 commit 13af7d5
Showing 1 changed file with 39 additions and 35 deletions.
74 changes: 39 additions & 35 deletions js/kunai/ui/badge.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,50 @@
const sanitize = (badges) => {
let i = 0

for (let b_raw of badges) {
++i

let b = $(b_raw)
const classes = b.attr('class').split(/\s+/).map(t => t.trim())
// const clean_txt = b.text().trim().replace(/\(([^)]+)\)/, '$1')

let deprecated_or_removed = false
let cppv = null
for (const c of classes) {
const cppm = c.match(/^cpp(\d[\da-zA-Z])(.*)$/)
if (!cppm) continue

b.attr('data-cpp-version', cppm[1])
if (cppm[1].length) {
cppv = cppm[1]
console.log("ui/badge.js:3==>", badges)
try{
for (let b_raw of badges) {
++i

let b = $(b_raw)
const classes = b.attr('class').split(/\s+/).map(t => t.trim())
// const clean_txt = b.text().trim().replace(/\(([^)]+)\)/, '$1')

let deprecated_or_removed = false
let cppv = null
for (const c of classes) {
const cppm = c.match(/^cpp(\d[\da-zA-Z])(.*)$/)
if (!cppm) continue

b.attr('data-cpp-version', cppm[1])
if (cppm[1].length) {
cppv = cppm[1]
}

if (c.match(/deprecated$/)) {
deprecated_or_removed = true
b.addClass('deprecated-spec')
} else if (c.match(/removed$/)) {
deprecated_or_removed = true
b.addClass('removed-spec')
}
}

if (c.match(/deprecated$/)) {
deprecated_or_removed = true
b.addClass('deprecated-spec')
} else if (c.match(/removed$/)) {
deprecated_or_removed = true
b.addClass('removed-spec')
if (!deprecated_or_removed) {
b.addClass('added-in-spec')
}
}

if (!deprecated_or_removed) {
b.addClass('added-in-spec')
}

const lang_path = cppv ? `/lang/cpp${cppv}` : `/lang`
const lang_path = cppv ? `/lang/cpp${cppv}` : `/lang`

b.html(
$('<a>').attr('href', `${lang_path}.html`)
.append($('<i>'))
// .append($('<span>').text(clean_txt))
)
b.html(
$('<a>').attr('href', `${lang_path}.html`)
.append($('<i>'))
// .append($('<span>').text(clean_txt))
)
}
}
finally {
return i
}
return i
}

export {sanitize}
Expand Down

0 comments on commit 13af7d5

Please sign in to comment.