Skip to content

Commit

Permalink
docs: support IE8+ for compat page
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamOfIce committed Mar 6, 2023
1 parent 207c190 commit a196433
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 97 deletions.
2 changes: 1 addition & 1 deletion docs/.vuepress/config.ts
Expand Up @@ -32,7 +32,7 @@ export default defineUserConfig({
sidebar: sidebarZh,
},
},
copyright: `&copy 2014-${new Date().getFullYear()} zloirock and contributors`,
copyright: `© 2014-${new Date().getFullYear()} zloirock and contributors`,
displayFooter: true,
plugins: {
blog: {
Expand Down
2 changes: 1 addition & 1 deletion docs/.vuepress/layouts/Compat.vue
Expand Up @@ -91,7 +91,7 @@ onMounted(async () => {
<CommonWrapper>
<NormalPage>
<template #contentAfter>
<table class="theme-hope-content compat">
<table class="theme-hope-content compat" id="table">
<tr>
<th>module</th>
<th
Expand Down
88 changes: 0 additions & 88 deletions docs/.vuepress/public/compat/browsers-runner.js

This file was deleted.

31 changes: 31 additions & 0 deletions docs/.vuepress/public/compat/legacy-runner.js
@@ -0,0 +1,31 @@
window.onload = function () {
var table = document.getElementById("table");
var tests = window.tests;

for (var i = 1; i < table.childNodes[0].childNodes.length; i++) {
var element = table.childNodes[0].childNodes[i];
if (element.tagName !== "TR") continue;

var moduleName = element.firstChild.firstChild.innerHTML;
var test = tests[moduleName];
var result;
try {
if (typeof test == "function") {
result = !!test();
} else if (t !== undefined) {
for (var t = 0; t < test.length; t++)
result = !!result && !!test[t].call(undefined);
}
} catch (error) {
result = false;
}

element.childNodes[2].innerHTML =
result === undefined
? "no available test"
: result
? "not required"
: "required";
element.childNodes[2].className = result === undefined ? "nodata" : result;
}
};
4 changes: 2 additions & 2 deletions docs/compat.md
Expand Up @@ -12,12 +12,12 @@ head:
src: /compat/tests.js
- - script
- nomodule: ""
src: /compat/browsers-runner.js
src: /compat/legacy-runner.js
---

## About

`core-js` project provides (as [`core-js-compat`](/packages/core-js-compat) package) all required data about the necessity of `core-js` modules, entry points, and tools for work with it - it's useful for integration with tools like `babel` or `swc`. If you wanna help, you could take a look at the related section of [`CONTRIBUTING.md`](/CONTRIBUTING.md#how-to-update-core-js-compat-data). The visualization of compatibility data and the browser tests runner is available below
`core-js` project provides (as [`core-js-compat`](/packages/core-js-compat) package) all required data about the necessity of `core-js` modules, entry points, and tools for work with it - it's useful for integration with tools like `babel` or `swc`. If you wanna help, you could take a look at the related section of [`CONTRIBUTING.md`](/dev/README.md#how-to-update-core-js-compat-data). The visualization of compatibility data and the browser tests runner is available below

Supported engines:
::: details
Expand Down
4 changes: 2 additions & 2 deletions docs/features/web-standard/README.md
Expand Up @@ -6,9 +6,9 @@ APIs that aren't part of ES, but are provided by browsers and available to JS co

- [`structuredClone`](structured-clone.md)
- [Base64 utility methods](base64-utility-methods.md)
- [`setTimeout` and `setInterval`](set-timeout%20and%20set-interval.md)
- [`setTimeout` and `setInterval`](set-timeout-and-set-interval.md)
- [`setImmediate`](set-immediate.md)
- [`queueMicrotask`](queue-microtask.md)
- [`URL` and `URLSearchParams`](url.md)
- [`DOMException`](dom-exception.md)
- [Iterable DOM collections](Iterable%20DOM%20collections.md)
- [Iterable DOM collections](dom-collections.md)
2 changes: 1 addition & 1 deletion scripts/copy-compat.js
@@ -1,5 +1,5 @@
await Promise.all(
["browsers-runner.js", "compat-data.js", "tests.js"].map((file) =>
["compat-data.js", "tests.js"].map((file) =>
fs.copy(`tests/compat/${file}`, `docs/.vuepress/public/compat/${file}`)
)
);
Expand Down
2 changes: 1 addition & 1 deletion tests/compat/browsers-runner.js
Expand Up @@ -4,7 +4,7 @@ function createElement(name, props) {
return element;
}

var table = document.getElementsByClassName('table')[0];
var table = document.getElementById('table');
var tests = window.tests;
var data = window.data;

Expand Down
2 changes: 1 addition & 1 deletion tests/compat/index.html
Expand Up @@ -32,7 +32,7 @@
text-align: center;
}
</style>
<table class='table'></table>
<table id='table'></table>
<script src='./compat-data.js'></script>
<script src='./tests.js'></script>
<script src='./browsers-runner.js'></script>

0 comments on commit a196433

Please sign in to comment.