From 4ef4a21830dcaedc5934a8d6c376b7b8ed1e7373 Mon Sep 17 00:00:00 2001 From: yumetodo Date: Sun, 12 Nov 2017 03:27:36 +0900 Subject: [PATCH 1/2] feat: replace Array.prototype.includes() to core-js polyfill manually --- js/kunai/code/cpp.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/kunai/code/cpp.js b/js/kunai/code/cpp.js index f339871..f172d16 100644 --- a/js/kunai/code/cpp.js +++ b/js/kunai/code/cpp.js @@ -2,6 +2,7 @@ import {ID} from './id' import {Logger} from 'nagato' +const arrayIncludes = require("core-js/library/fn/array/includes") class CPP { constructor(log, id, buf, hints) { @@ -27,7 +28,7 @@ class CPP { if (hints.headers) { for (const h of hints.headers) { - if (!this.headers.includes(h)) { + if (!arrayIncludes(this.headers, h)) { this.log.warn(`already found header '${h}' in meta tag, but it was not written in this code snippet`) this.prepend_header(h) this.headers.push(h) From 13af7d56d02402636d8cba284bb259b33eb55a55 Mon Sep 17 00:00:00 2001 From: yumetodo Date: Sun, 12 Nov 2017 03:28:09 +0900 Subject: [PATCH 2/2] 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}