- If the target rule represents a style rule;
- If the target rule style contains a fallback contain property;
1. If the fallback contain property represents a layout container;
- For each element matching the selector of the target rule;
- Add the element to the list of layout containers, then;
- Add a fallback layout containment rule for that specific element.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { existsSync } from 'fs' | |
import { readFile } from 'fs/promises' | |
import { transform } from 'esbuild' | |
/** @typedef {{ conditions: string[], parentURL: string }} Context */ | |
/** @typedef {(specifier: string, context: Context, defaultResolve: ResolveHook) => { url: string }} ResolveHook */ | |
/** @typedef {(url: string, context: Context, defaultGetFormat: GetFormatHook) => { format: string }} GetFormatHook */ | |
/** @typedef {(url: string, context: Context, defaultGetSource: GetSourceHook) => Promise<{ source: string | SharedArrayBuffer | Uint8Array }>} GetSourceHook */ | |
/** Matches any JavaScript/TypeScript module. */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
new CSSStyleSheet() | |
} catch { | |
CSSStyleSheet = (( | |
stylePtt = CSSStyleSheet.prototype, | |
styleDoc = new Document(), | |
styleDom = styleDoc.appendChild(document.createElement('style')), | |
sheet | |
) => Object.assign(stylePtt.constructor = function CSSStyleSheet() { | |
if (!new.target) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Observes stylesheet lists and runs a callback whenever it encounteres added or removed stylesheets. */ | |
export const createStyleSheetObserver = (/** @type {(addedSheets?: CSSStyleSheet[], removedSheets?: CSSStyleSheet[]) => void} */ callback) => { | |
/** @type {Set<StyleSheetList>} Observed style sheet lists. */ | |
const sheetLists = new Set | |
/** @type {Set<CSSStyleSheet>} Previously observed style sheets. */ | |
let lastSheets = new Set | |
/** Observes style sheet on each animation frame. */ | |
const onAnimationFrame = () => { | |
requestAnimationFrame(onAnimationFrame) | |
/** @type {CSSStyleSheet[]} Observed StyleSheets after this frame. */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
"align-content", | |
"align-items", | |
"align-self", | |
"alignment-baseline", | |
"all", | |
"animation", | |
"animation-delay", | |
"animation-direction", | |
"animation-duration", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deepAssign(objectA, objectB) { | |
for (var n in objectB) { | |
var objectBN = objectB[n] | |
if (objectBN === Object(objectBN)) { | |
var objectAN = objectA[n] | |
if (objectAN === Object(objectAN)) { | |
objectA[n] = deepAssign(objectAN, objectBN) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default new Proxy( | |
Object.entries({ | |
reset: 0, | |
bold: 1, | |
dim: 2, | |
underline: 4, | |
blink: 5, | |
invert: 7, | |
hidden: 8, | |
black: 30, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
( | |
d, | |
c = d.createElement('b').style, | |
a = c.gap = 0, | |
polyfillList = new WeakMap, | |
ungapful = /^(normal|0px)+$/, | |
polyfillNode = element => { | |
if (polyfillList.has(element)) return | |
polyfillList.set(element, true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Returns a unique identifier tied to the document in the window on which it was created. */ | |
const createObjectUID = (): string => URL.createObjectURL(new Blob()).slice(-5) |