|
46 | 46 | background-color: grey; |
47 | 47 | } |
48 | 48 | </style> |
49 | | - <script type="module" defer> |
50 | | - import {isSupported, isPolyfilled, baseSupport, apply, polyfills} from '../lib/index.js' |
51 | | - // import {isSupported, isPolyfilled, apply, poyfills} from 'https://unpkg.com/@github/browser-support@latest/lib/index.js' |
52 | | - for(const el of document.querySelectorAll('[data-code]')) { |
53 | | - let supported = false |
54 | | - const code = el.getAttribute('data-code') |
55 | | - try { |
56 | | - if (code === "isSupported()") { |
57 | | - supported = isSupported() |
58 | | - } else if (code === "baseSupport") { |
59 | | - supported = baseSupport |
60 | | - } else if (code === "isPolyfilled()") { |
61 | | - supported = isPolyfilled() |
62 | | - } else { |
63 | | - supported = eval(`${code}`) |
64 | | - } |
65 | | - } catch (e) { |
66 | | - |
67 | | - } |
68 | | - Promise.resolve(supported).then((value) => { |
69 | | - el.setAttribute('data-supported', Boolean(value)) |
70 | | - if (!value && el.hasAttribute('data-transpiled')) { |
71 | | - if (!value) el.textContent = '**' |
72 | | - } |
73 | | - }) |
74 | | - } |
75 | | - for(const el of document.querySelectorAll('[data-polyfill]')) { |
76 | | - const name = el.getAttribute('data-polyfill') || '' |
77 | | - if (!(name in polyfills)) continue |
78 | | - Promise.resolve(polyfills[name].isSupported()).then((value) => { |
79 | | - el.setAttribute('data-supported', Boolean(value)) |
80 | | - if (!value) el.textContent = '*' |
81 | | - }) |
82 | | - } |
83 | | - </script> |
84 | 49 | </head> |
85 | 50 | <body> |
86 | 51 | <table> |
|
679 | 644 | el.setAttribute('data-supported', Boolean(value)) |
680 | 645 | if (!value && el.hasAttribute('data-transpiled')) { |
681 | 646 | if (!value) el.textContent = '**' |
| 647 | + } else if (!value && el.hasAttribute('data-polyfilled')) { |
| 648 | + if (!value) el.textContent = '*' |
| 649 | + } |
| 650 | + }) |
| 651 | + } |
| 652 | + </script> |
| 653 | + <script type="module"> |
| 654 | + import * as support from '../lib/index.js' |
| 655 | + // import * as support from 'https://unpkg.com/@github/browser-support@latest/lib/index.js' |
| 656 | + const polyfills = support.polyfills |
| 657 | + for(const el of document.querySelectorAll('[data-export]')) { |
| 658 | + let supported = false |
| 659 | + const key = el.getAttribute('data-export') |
| 660 | + if (key in support && typeof support[key] === 'function') { |
| 661 | + supported = Boolean(support[key]()) |
| 662 | + } else if (key in support) { |
| 663 | + supported = Boolean(support[key]) |
| 664 | + } else { |
| 665 | + supported = false |
| 666 | + } |
| 667 | + Promise.resolve(supported).then((value) => { |
| 668 | + el.setAttribute('data-supported', Boolean(value)) |
| 669 | + if (!value && el.hasAttribute('data-transpiled')) { |
| 670 | + if (!value) el.textContent = '**' |
| 671 | + } else if (!value && el.hasAttribute('data-polyfilled')) { |
| 672 | + if (!value) el.textContent = '*' |
| 673 | + } |
| 674 | + }) |
| 675 | + } |
| 676 | + for(const el of document.querySelectorAll('[data-polyfill]')) { |
| 677 | + let supported = false |
| 678 | + const name = el.getAttribute('data-polyfill') || '' |
| 679 | + if (name in polyfills) { |
| 680 | + supported = polyfills[name].isSupported() |
| 681 | + } else { |
| 682 | + supported = false |
| 683 | + } |
| 684 | + Promise.resolve(supported).then((value) => { |
| 685 | + el.setAttribute('data-supported', Boolean(value)) |
| 686 | + if (!value && el.hasAttribute('data-transpiled')) { |
| 687 | + if (!value) el.textContent = '**' |
| 688 | + } else if (!value && el.hasAttribute('data-polyfilled')) { |
| 689 | + if (!value) el.textContent = '*' |
682 | 690 | } |
683 | 691 | }) |
684 | 692 | } |
|
0 commit comments