From 13af7d56d02402636d8cba284bb259b33eb55a55 Mon Sep 17 00:00:00 2001 From: yumetodo Date: Sun, 12 Nov 2017 03:28:09 +0900 Subject: [PATCH] fix(IE11): quash exception [dirty hack] ref: - https://github.com/cpprefjp/site/issues/477 --- js/kunai/ui/badge.js | 74 +++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/js/kunai/ui/badge.js b/js/kunai/ui/badge.js index dafb062..7f739e2 100644 --- a/js/kunai/ui/badge.js +++ b/js/kunai/ui/badge.js @@ -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( - $('').attr('href', `${lang_path}.html`) - .append($('')) - // .append($('').text(clean_txt)) - ) + b.html( + $('').attr('href', `${lang_path}.html`) + .append($('')) + // .append($('').text(clean_txt)) + ) + } + } + finally { + return i } - return i } export {sanitize}