MCPcopy Create free account
hub / github.com/dailydotdev/apps / inline

Function inline

packages/shared/src/features/interests/nodeToPng.ts:4–26  ·  view source on GitHub ↗
(source: Element, clone: Element)

Source from the content-addressed store, hash-verified

2// a plain card. Two limits the card is built around: pseudo-elements are not
3// cloned, and an SVG foreignObject cannot reach the page's webfonts.
4const inline = (source: Element, clone: Element): void => {
5 const computed = getComputedStyle(source);
6 let css = '';
7
8 for (let index = 0; index < computed.length; index += 1) {
9 const property = computed.item(index);
10
11 css += `${property}:${computed.getPropertyValue(property)};`;
12 }
13
14 clone.setAttribute('style', css);
15
16 const sources = Array.from(source.children);
17 const clones = Array.from(clone.children);
18
19 sources.forEach((child, index) => {
20 const pair = clones[index];
21
22 if (pair) {
23 inline(child, pair);
24 }
25 });
26};
27
28export const nodeToPng = async (
29 node: HTMLElement,

Callers 1

nodeToPngFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected