UNPKG

gatsby-plugin-fix-fouc

Version:

Gatsby Plugin Fix FOUC is a plugin that solves flicker of unstyled content

31 lines (30 loc) 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.defaultOptions = void 0; exports.toCamelCase = toCamelCase; /** * Name conversion * dash-style to camelCase conversion * A custom data attribute name is transformed to a key for the DOMStringMap entry by the following: * * 1. Lowercase all ASCII capital letters (A to Z); * 2. Remove the prefix data- (including the dash); * 3. For any dash (U+002D) followed by an ASCII lowercase letter a to z, remove the dash and uppercase the letter; * 4. Other characters (including other dashes) are left unchanged. * * https://github.com/mdn/content/blob/aa6e900e44ed7e9c3612b98abdb51cb4ab4d99e1/files/en-us/web/api/htmlelement/dataset/index.md * (c) Mozilla Contributors (CC-BY-SA-2.5) */ function toCamelCase(dataAttr) { // Remove the 'data-' prefix and convert to lowercase var s = dataAttr.replace("data-", "").toLowerCase(); // Convert any '-x' to 'X' return s.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); }); } exports.defaultOptions = { attributeName: "gatsby-plugin-fix-fouc-is-loading", minWidth: 0, timeout: 4000, };