Remove unused polyfills and adjust support for Intl.getCanonicalLocales (#23264)

pull/23278/head
Steve Repsher 2024-12-12 08:07:50 -05:00 committed by GitHub
parent e9b2a83411
commit 145a536156
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 11 additions and 87 deletions

View File

@ -5,7 +5,7 @@ import paths from "../paths.cjs";
const POLYFILL_DIR = join(paths.polymer_dir, "src/resources/polyfills");
// List of polyfill keys with supported browser targets for the functionality
const PolyfillSupport = {
const polyfillSupport = {
// Note states and shadowRoot properties should be supported.
"element-internals": {
android: 90,
@ -18,17 +18,6 @@ const PolyfillSupport = {
safari: 17.4,
samsung: 15.0,
},
"element-append": {
android: 54,
chrome: 54,
edge: 17,
firefox: 49,
ios: 10.0,
opera: 41,
opera_mobile: 41,
safari: 10.0,
samsung: 6.0,
},
"element-getattributenames": {
android: 61,
chrome: 61,
@ -51,27 +40,18 @@ const PolyfillSupport = {
safari: 12.0,
samsung: 10.0,
},
fetch: {
android: 42,
chrome: 42,
edge: 14,
firefox: 39,
ios: 10.3,
opera: 29,
opera_mobile: 29,
safari: 10.1,
samsung: 4.0,
},
// FormatJS polyfill detects fix for https://bugs.chromium.org/p/v8/issues/detail?id=10682,
// so adjusted to several months after that was marked fixed
"intl-getcanonicallocales": {
android: 54,
chrome: 54,
edge: 16,
android: 90,
chrome: 90,
edge: 90,
firefox: 48,
ios: 10.3,
opera: 41,
opera_mobile: 41,
opera: 76,
opera_mobile: 64,
safari: 10.1,
samsung: 6.0,
samsung: 15.0,
},
"intl-locale": {
android: 74,
@ -87,17 +67,6 @@ const PolyfillSupport = {
"intl-other": {
// Not specified (i.e. always try polyfill) since compatibility depends on supported locales
},
proxy: {
android: 49,
chrome: 49,
edge: 12,
firefox: 18,
ios: 10.0,
opera: 36,
opera_mobile: 36,
safari: 10.0,
samsung: 5.0,
},
"resize-observer": {
android: 64,
chrome: 64,
@ -115,8 +84,6 @@ const PolyfillSupport = {
// corresponding polyfill key and actual module to import
const polyfillMap = {
global: {
fetch: { key: "fetch", module: "unfetch/polyfill" },
Proxy: { key: "proxy", module: "proxy-polyfill" },
ResizeObserver: {
key: "resize-observer",
module: join(POLYFILL_DIR, "resize-observer.ts"),
@ -128,7 +95,7 @@ const polyfillMap = {
module: "element-internals-polyfill",
},
...Object.fromEntries(
["append", "getAttributeNames", "toggleAttribute"].map((prop) => {
["getAttributeNames", "toggleAttribute"].map((prop) => {
const key = `element-${prop.toLowerCase()}`;
return [prop, { key, module: join(POLYFILL_DIR, `${key}.ts`) }];
})
@ -168,7 +135,7 @@ export default defineProvider(
const resolvePolyfill = createMetaResolver(polyfillMap);
return {
name: "custom-polyfill",
polyfills: PolyfillSupport,
polyfills: polyfillSupport,
usageGlobal(meta, utils) {
const polyfill = resolvePolyfill(meta);
if (polyfill && shouldInjectPolyfill(polyfill.desc.key)) {

View File

@ -128,7 +128,6 @@
"marked": "15.0.3",
"memoize-one": "6.0.0",
"node-vibrant": "3.2.1-alpha.1",
"proxy-polyfill": "0.3.2",
"punycode": "2.3.1",
"qr-scanner": "1.4.2",
"qrcode": "1.5.4",
@ -141,7 +140,6 @@
"tsparticles-engine": "2.12.0",
"tsparticles-preset-links": "2.12.0",
"ua-parser-js": "1.0.39",
"unfetch": "5.0.0",
"vis-data": "7.1.9",
"vis-network": "9.1.9",
"vue": "2.7.16",

View File

@ -1,25 +0,0 @@
// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/append()/append().md
(function (arr) {
arr.forEach((item) => {
if (Object.prototype.hasOwnProperty.call(item, "append")) {
return;
}
Object.defineProperty(item, "append", {
configurable: true,
enumerable: true,
writable: true,
value: function append(...argArr) {
const docFrag = document.createDocumentFragment();
argArr.forEach((argItem) => {
const isNode = argItem instanceof Node;
docFrag.appendChild(
isNode ? argItem : document.createTextNode(String(argItem))
);
});
this.appendChild(docFrag);
},
});
});
})([Element.prototype, Document.prototype, DocumentFragment.prototype]);

View File

@ -9315,7 +9315,6 @@ __metadata:
open: "npm:10.1.0"
pinst: "npm:3.0.0"
prettier: "npm:3.4.2"
proxy-polyfill: "npm:0.3.2"
punycode: "npm:2.3.1"
qr-scanner: "npm:1.4.2"
qrcode: "npm:1.5.4"
@ -9336,7 +9335,6 @@ __metadata:
tsparticles-preset-links: "npm:2.12.0"
typescript: "npm:5.7.2"
ua-parser-js: "npm:1.0.39"
unfetch: "npm:5.0.0"
vis-data: "npm:7.1.9"
vis-network: "npm:9.1.9"
vitest: "npm:2.1.8"
@ -12319,13 +12317,6 @@ __metadata:
languageName: node
linkType: hard
"proxy-polyfill@npm:0.3.2":
version: 0.3.2
resolution: "proxy-polyfill@npm:0.3.2"
checksum: 10/0e43c8ba9cc14d3ce12d029f5647b8c03120fb0b912a176bcb8fb2c560f8fb94e49f89707b6e2df0443e3514d0bb63cc1960d671b39904b479bb09e4ae7e09a4
languageName: node
linkType: hard
"punycode@npm:2.3.1, punycode@npm:^2.1.0, punycode@npm:^2.3.1":
version: 2.3.1
resolution: "punycode@npm:2.3.1"
@ -14532,13 +14523,6 @@ __metadata:
languageName: node
linkType: hard
"unfetch@npm:5.0.0":
version: 5.0.0
resolution: "unfetch@npm:5.0.0"
checksum: 10/8a59f9d910f179ef588aa30885849de7b4c895a85b3679ab4da7305be3751b85a4811d9164d87960fef1a388b9a7afdc23ab2154f517db040b27171578fa9e8b
languageName: node
linkType: hard
"unicode-canonical-property-names-ecmascript@npm:^2.0.0":
version: 2.0.1
resolution: "unicode-canonical-property-names-ecmascript@npm:2.0.1"