Fixed site loading in older versions of safari

This commit is contained in:
Mitchell McCaffrey 2020-04-07 12:48:10 +10:00
parent b0fdabefcb
commit a905ce378b
2 changed files with 13 additions and 1 deletions

View File

@ -1,11 +1,13 @@
import React from "react"; import React from "react";
import { Image } from "theme-ui"; import { Image } from "theme-ui";
import { fromEntries } from "../helpers/shared";
// The data prop is used to pass data into the dom element // The data prop is used to pass data into the dom element
// this can be used to pass state to the ProxyToken // this can be used to pass state to the ProxyToken
function Token({ image, className, data, sx }) { function Token({ image, className, data, sx }) {
// Map the keys in data to have the `data-` prefix // Map the keys in data to have the `data-` prefix
const dataProps = Object.fromEntries( const dataProps = fromEntries(
Object.entries(data).map(([key, value]) => [`data-${key}`, value]) Object.entries(data).map(([key, value]) => [`data-${key}`, value])
); );
return ( return (

View File

@ -8,3 +8,13 @@ export function omit(obj, keys) {
} }
return tmp; return tmp;
} }
export function fromEntries(iterable) {
if (Object.fromEntries) {
return Object.fromEntries(iterable);
}
return [...iterable].reduce((obj, [key, val]) => {
obj[key] = val;
return obj;
}, {});
}