Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support IE11 #26

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions js/crsearch/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import URL from 'url-parse'

import * as Query from './query'

const arrayEntries = require('core-js/library/fn/array/entries')
const arrayIncludes = require("core-js/library/fn/array/includes")

class Database {
constructor(log, json) {
Expand All @@ -33,7 +35,7 @@ class Database {

this.log.debug('[P1] initializing all IndexID...')
let fallback_001_used = false
for (const [s_key, id] of json.ids.entries()) {
for (const [s_key, id] of arrayEntries(json.ids)) {
const iid = new IndexID(this.log, s_key, id)

// legacy fallback
Expand Down Expand Up @@ -61,7 +63,7 @@ class Database {
}

this.log.debug('[P1] initializing all Namespace...')
for (const [s_key, j_ns] of json.namespaces.entries()) {
for (const [s_key, j_ns] of arrayEntries(json.namespaces)) {
const ns = new Namespace(this.log, s_key, j_ns, this.ids, this.make_url.bind(this))
this.log.debug(`got Namespace: '${ns.pretty_name()}'`, ns)
this.namespaces.push(ns)
Expand Down Expand Up @@ -110,7 +112,7 @@ class Database {

this.all_classes.get(cand).members.add(idx)

} else if ([IType.article, IType.meta].includes(idx.id.type)) {
} else if (arrayIncludes([IType.article, IType.meta], idx.id.type)) {
if (idx.isRootArticle()) {
this.root_articles.set(
idx.ns,
Expand Down
4 changes: 3 additions & 1 deletion js/crsearch/dom.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const arrayIncludes = require("core-js/library/fn/array/includes")

class DOM {
static defaultOptions = {
links: {
Expand Down Expand Up @@ -34,7 +36,7 @@ class DOM {
}
}

if (['deprecated_in_latest', 'removed_in_latest', 'added_in_latest'].includes(attr)) {
if (arrayIncludes(['deprecated_in_latest', 'removed_in_latest', 'added_in_latest'], attr)) {
li.addClass('latest-spec')
}
}
Expand Down
12 changes: 7 additions & 5 deletions js/crsearch/index-id.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {IndexType as IType} from './index-type'

const arrayIncludes = require("core-js/library/fn/array/includes")

class IndexID {
static VERBATIM_TRS = new Map([
['コンストラクタ', {to: '(constructor)', only: IType.mem_fun}],
Expand Down Expand Up @@ -31,7 +33,7 @@ class IndexID {
}

static isClassy(type) {
return [IType.class, IType.function, IType.mem_fun, IType.enum, IType.variable, IType.type_alias].includes(type)
return arrayIncludes([IType.class, IType.function, IType.mem_fun, IType.enum, IType.variable, IType.type_alias], type)
}

constructor(log, s_key, json) {
Expand Down Expand Up @@ -66,20 +68,20 @@ class IndexID {
keys = ns.concat(keys)
}
this.cpp_namespace = keys
this.keys = keys.map((k) => k.normalize('NFKC'))
this.keys = (typeof String.prototype.normalize === 'function') ? keys.map((k) => k.normalize('NFKC')) : keys

for (const [k, v] of IndexID.VERBATIM_TRS) {
if (v.only && ![].concat(v.only).includes(this.type)) {
if (v.only && !arrayIncludes([].concat(v.only), this.type)) {
continue
}

if (this.keys[this.keys.length - 1].includes(k)) {
if (arrayIncludes(this.keys[this.keys.length - 1], k)) {
this.keys[this.keys.length - 1] = this.keys[this.keys.length - 1].replace(k, `${v.to}`)

if (v.type) {
this.type = v.type

if ([IType.class, IType.mem_fun].includes(this.type) && this.keys[0] !== 'std') {
if (arrayIncludes([IType.class, IType.mem_fun], this.type) && this.keys[0] !== 'std') {
this.keys.unshift('std')
}
}
Expand Down
9 changes: 5 additions & 4 deletions js/crsearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {IndexID} from './index-id'

import {DOM} from './dom'

const arrayIncludes = require("core-js/library/fn/array/includes")

class Index {
constructor(log, cpp_version, id, json, make_url) {
Expand Down Expand Up @@ -30,7 +31,7 @@ class Index {
}

isRootArticle() {
return this.page_id[0].length === 0 /* && [IType.meta, IType.article].includes(this.id.type) */
return this.page_id[0].length === 0 /* && arrayIncludes([IType.meta, IType.article], this.id.type) */
}

isParent() {
Expand Down Expand Up @@ -80,11 +81,11 @@ class Index {
}

static ambgMatch(idx, q) {
if ([IType.article, IType.meta].includes(idx.id.type)) {
return idx.id_cache.toLowerCase().includes(q.toLowerCase())
if (arrayIncludes([IType.article, IType.meta], idx.id.type)) {
return arrayIncludes(idx.id_cache.toLowerCase(), q.toLowerCase())
}

return idx.id_cache.includes(q)
return arrayIncludes(idx.id_cache, q)
}
}

Expand Down
2 changes: 1 addition & 1 deletion js/crsearch/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Query {
constructor(log, text) {
this.log = log.makeContext('Query')
this.original_text = text
this.frags = text.normalize('NFKC').split(/\s+/).filter(Boolean)
this.frags = ((typeof String.prototype.normalize === 'function') ? text.normalize('NFKC') : text).split(/\s+/).filter(Boolean)

this.filters = new Set

Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"cssnano": "^4.0.0-rc.2",
"expose-loader": "^0.7.3",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^0.11.2",
"file-loader": "^1.1.5",
"handlebars": "^4.0.11",
"handlebars-loader": "^1.6.0",
"html-webpack-include-assets-plugin": "0.0.7",
"html-webpack-include-assets-plugin": "1.0.2",
"html-webpack-plugin": "^2.30.1",
"mousetrap": "^1.6.1",
"node-sass": "^4.6.0",
Expand All @@ -51,17 +51,18 @@
"precss": "^2.0.0",
"raw-loader": "^0.5.1",
"sass-loader": "^6.0.6",
"style-loader": "^0.18.2",
"style-loader": "^0.19.0",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.9.4",
"webpack-merge": "^4.1.1"
},
"dependencies": {
"babel-runtime": "^6.26.0",
"core-js": "^2.5.1",
"font-awesome": "^4.7.0",
"jquery": "^3.2.1",
"marked": "^0.3.6",
"nagato": "^1.8.2",
"nagato": "^1.8.3",
"url-parse": "^1.2.0"
}
}