fix: plugins not loaded with legacy dev (#1764)
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
This commit is contained in:
co-authored by
Marvin Hagemeister
parent
42dc54500c
commit
ec2f785455
+38
-3
@@ -10,8 +10,9 @@ import {
|
||||
TextLineStream,
|
||||
} from "./deps.ts";
|
||||
|
||||
export function parseHtml(input: string) {
|
||||
return new DOMParser().parseFromString(input, "text/html");
|
||||
export function parseHtml(input: string): Document {
|
||||
// deno-lint-ignore no-explicit-any
|
||||
return new DOMParser().parseFromString(input, "text/html") as any;
|
||||
}
|
||||
|
||||
export async function startFreshServer(options: Deno.CommandOptions) {
|
||||
@@ -87,7 +88,6 @@ export const VOID_ELEMENTS =
|
||||
/^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;
|
||||
function prettyDom(doc: Document) {
|
||||
let out = colors.dim(`<!DOCTYPE ${doc.doctype?.name ?? ""}>\n`);
|
||||
console.log(out);
|
||||
|
||||
const node = doc.documentElement;
|
||||
out += _printDomNode(node, 0);
|
||||
@@ -269,6 +269,41 @@ export async function waitForText(
|
||||
);
|
||||
}
|
||||
|
||||
export async function waitForStyle(
|
||||
page: Page,
|
||||
selector: string,
|
||||
name: keyof CSSStyleDeclaration,
|
||||
value: string,
|
||||
) {
|
||||
await page.waitForSelector(selector);
|
||||
|
||||
const start = Date.now();
|
||||
let now = start;
|
||||
let found = false;
|
||||
while (now < start + 2000) {
|
||||
found = await page.evaluate(
|
||||
(s, n, v) => {
|
||||
const el = document.querySelector(s);
|
||||
if (!el) return false;
|
||||
return window.getComputedStyle(el)[n] === v;
|
||||
},
|
||||
selector,
|
||||
name,
|
||||
value,
|
||||
);
|
||||
|
||||
if (found) break;
|
||||
|
||||
await delay(200);
|
||||
now = Date.now();
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
console.log(prettyDom(parseHtml(await page.content())));
|
||||
throw new Error(`Could not find style ${String(name)}: ${value}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function spawnServer(
|
||||
options: Deno.CommandOptions,
|
||||
expectErrors = false,
|
||||
|
||||
Reference in New Issue
Block a user