Skip to content

Commit d9ee199

Browse files
committed
Convert the generator to an async function
1 parent 6235805 commit d9ee199

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

src/Generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface Options {
1111
* @param css The style sheet.
1212
* @returns An HTML body element containing the generated DOM.
1313
*/
14-
export function cssToHtml(css: CSSRuleList | string, options: Options = {}): HTMLBodyElement {
14+
export async function cssToHtml(css: CSSRuleList | string, options: Options = {}): Promise<HTMLBodyElement> {
1515
const output = document.createElement('body');
1616
const fillerElements = [] as HTMLElement[];
1717
function isFillerElement (element: HTMLElement | Element): boolean {

tests/cascading.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test('Cascading', async ({ page }) => {
2020
await page.addScriptTag({ path: './dist/Generator.script.js' });
2121

2222
const result = await page.evaluate(async (css) => {
23-
document.body = cssToHtml(css);
23+
document.body = await cssToHtml(css);
2424
const styleElement = document.createElement('style');
2525
styleElement.innerText = css;
2626
document.head.append(styleElement);

tests/comma.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test('Comma', async ({ page }) => {
1717
await page.addScriptTag({ path: './dist/Generator.script.js' });
1818

1919
const result = await page.evaluate(async (css) => {
20-
document.body = cssToHtml(css);
20+
document.body = await cssToHtml(css);
2121

2222
return document.body.querySelector('h1')?.innerHTML === 'a'
2323
&& document.body.querySelector('p.subtitle')?.innerHTML === 'a'

tests/ignored.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test('Ignored', async ({ page }) => {
2727
await page.addScriptTag({ path: './dist/Generator.script.js' });
2828

2929
const result = await page.evaluate(async (css) => {
30-
document.body = cssToHtml(css);
30+
document.body = await cssToHtml(css);
3131

3232
const element = document.body.querySelector('div');
3333
return element

tests/nth-child.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test('Nth-Child', async ({ page }) => {
2424
await page.addScriptTag({ path: './dist/Generator.script.js' });
2525

2626
const result = await page.evaluate(async (css) => {
27-
document.body = cssToHtml(css);
27+
document.body = await cssToHtml(css);
2828

2929
return document.body.querySelectorAll('*').length === 10
3030
&& document.body.querySelector('div.first')?.previousElementSibling === null

tests/selector.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test('Selector', async ({ page }) => {
2525
await page.addScriptTag({ path: './dist/Generator.script.js' });
2626

2727
const result = await page.evaluate(async ([css, html]) => {
28-
document.body = cssToHtml(css);
28+
document.body = await cssToHtml(css);
2929
const styleElement = document.createElement('style');
3030
styleElement.innerText = css;
3131
document.head.append(styleElement);

0 commit comments

Comments
 (0)