Skip to content

Commit

Permalink
Merge pull request #85 from alienzhou/fix/compatibility-ie-regexp
Browse files Browse the repository at this point in the history
fix(compatibility): fix some compatibilities in ie11
  • Loading branch information
alienzhou authored Jun 24, 2021
2 parents 2bde715 + e7906cd commit 21de8d0
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,10 @@ module.exports = {
"ignoreRestSiblings": true
}
],
"@typescript-eslint/prefer-includes": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/prefer-readonly-parameter-types": "off",
"@typescript-eslint/prefer-string-starts-ends-with": "off",
"@typescript-eslint/promise-function-async": "off",
"@typescript-eslint/restrict-template-expressions": [
"warn",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ Hooks let you control the highlighting flow powerfully. You can almost customize

> It depends on [Selection API](https://caniuse.com/#search=selection%20api).
- IE 10、11
- IE 11
- Edge
- Firefox 52+
- Chrome 15+
Expand Down
2 changes: 1 addition & 1 deletion README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ highlighter.on(Highlighter.event.CREATE, function (data, inst, e) {

> 依赖 [Selection API](https://caniuse.com/#search=selection%20api)
- IE 10、11
- IE 11
- Edge
- Firefox 52+
- Chrome 15+
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"serve-example": "http-server example/static",
"serve": "http-server -p 8081 ./dist",
"watch": "webpack --config ./config/webpack.config.prod.js --watch",
"build-example": "export target=example && node script/build.js",
"build-example": "target=example node script/build.js",
"static": "run-p watch serve",
"start": "node script/dev.js",
"build:types": "tscpaths -p tsconfig.json -s ./src -o ./dist",
Expand Down
8 changes: 4 additions & 4 deletions src/painter/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ const isMatchSelector = ($node: HTMLElement, selector: string): boolean => {
return false;
}

if (selector.startsWith('.')) {
const className = selector.replace(/^\./u, '');
if (/^\./.test(selector)) {
const className = selector.replace(/^\./, '');

return $node && hasClass($node, className);
} else if (selector.startsWith('#')) {
const id = selector.replace(/^#/u, '');
} else if (/^#/.test(selector)) {
const id = selector.replace(/^#/, '');

return $node && $node.id === id;
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Hook<T = unknown> {
}

tap(cb: HookCallback<T>) {
if (!this.ops.includes(cb)) {
if (this.ops.indexOf(cb) === -1) {
this.ops.push(cb);
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/is.mobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
* is mobile device?
*/

const regMobile = /Android|iPhone|BlackBerry|BB10|Opera Mini|Phone|Mobile|Silk|Windows Phone|Mobile(?:.+)Firefox\b/iu;
const regMobile = /Android|iPhone|BlackBerry|BB10|Opera Mini|Phone|Mobile|Silk|Windows Phone|Mobile(?:.+)Firefox\b/i;

export default (userAgent: string) => regMobile.test(userAgent);
2 changes: 1 addition & 1 deletion src/util/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const unique = <T>(arr: T[]): T[] => {
const res: T[] = [];

for (const el of arr) {
if (!res.includes(el)) {
if (res.indexOf(el) === -1) {
res.push(el);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/uuid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
export default function createUUID(a?): string {
return a
? (a ^ ((Math.random() * 16) >> (a / 4))).toString(16)
: ((([1e7] as unknown) as string) + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/gu, createUUID);
: ((([1e7] as unknown) as string) + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, createUUID);
}

0 comments on commit 21de8d0

Please sign in to comment.