Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix linkedom + inline usage #1

Open
wants to merge 6 commits into
base: feat/linkedom
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/dom.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
// export * from "https://deno.land/x/deno_dom@v0.1.45/deno-dom-wasm.ts";
export * from "https://esm.sh/linkedom@0.16.11";
export * from "https://esm.sh/linkedom@0.16.11";
5 changes: 4 additions & 1 deletion plugins/inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ export default function (userOptions?: Options) {
page.document!.querySelectorAll("template"),
)
.flatMap((template) =>
Array.from(template.content.querySelectorAll(selector))
Array.from(
template.childNodes.length === 0 ?
template.content.querySelectorAll(selector) :
template.querySelectorAll(selector) )
);
for (
const element of [
Expand Down
10 changes: 5 additions & 5 deletions tests/__snapshots__/esbuild.test.ts.snap

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/__snapshots__/inline.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ const a = 1, _b = 1 < a, _c = a > 4;
const a = 1, _b = 1 < a, _c = a > 4;
</script>
<template>
<svg width="126px" height="126px" viewbox="0 0 126 126" version="1.1" xmlns="http://www.w3.org/2000/svg" xlink="http://www.w3.org/1999/xlink" id="el-14" class="has-svg">
<svg class="has-svg" id="el-14" width="126px" height="126px" viewBox="0 0 126 126" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>favicon</title>
<g id="favicon" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M52.8683497,7.99450751 C48.9069025,24.0969979 69.1669662,21.1536885 69.1669662,44.7198348 C75.794917,37.1051328 70.4463322,26.8453748 81.058456,17.1725913 C81.058456,39.3863344 102.155357,38.1365645 94.0121919,69.2249916 C97.7866664,66.9118477 100.501055,63.103682 102.155357,57.8004944 C105.491398,63.103682 104.245257,72.5297487 98.416934,86.0786945 C103.547554,83.9150474 106.558165,80.9232746 108.378132,76.7271327 C109.04106,105.964869 89.5062156,126.366871 61.9867103,125.995028 C34.467205,125.623185 13.5784967,101.642443 18.2649214,71.802957 C18.9624768,74.9072731 21.5182769,78.5533566 25.1832626,80.0729101 C18.6891247,50.7321037 30.922502,49.6337285 36.0056643,33.9730813 C35.1796585,42.297059 36.0056643,46.924952 40.0208236,51.7593505 C40.7309276,49.6474958 42.0145668,47.6388953 43.3724725,45.627895 L43.7620351,45.0531669 C43.8271552,44.9573376 43.892336,44.86148 43.9575234,44.7655828 L44.5429346,43.9011285 C47.3268507,39.7628977 49.8240593,35.4880393 47.7482658,30.1694988 C44.3690672,21.5114095 44.6913719,18.1446262 52.8683497,7.99450751 Z M43.4168797,15.6028981 C41.2434833,17.8205255 41.7153274,24.275166 44.213695,29.9427578 C46.7120625,35.6103495 43.4168797,39.8756006 39.8854597,45.126676 C40.5019929,38.1390602 39.8587244,36.4802473 36.8588412,31.1077941 C33.858958,25.7353408 37.9685715,18.6230687 43.4168797,15.6028981 Z M64.7721431,8.03208837 C69.8550649,12.4485247 71.6576876,12.8901943 72.209291,17.4374541 C72.7608943,21.9847139 70.2967086,24.09635 71.2822168,30.0346208 C60.9002329,21.508497 69.0471936,18.4710785 64.7721431,8.03208837 Z M53.3587168,1.6350624e-05 C57.0113944,4.33013045 59.1813933,3.19675313 61.5638477,8.73089813 C63.9463021,14.2650431 60.9615342,15.5202483 63,22.1753596 C51.0029851,11.8529541 58.4461322,11.0173257 53.3587168,1.6350624e-05 Z" id="Combined-Shape-Copy" fill="#C84F46"></path>
<path d="M52.8683497,7.99450751 C48.9069025,24.0969979 69.1669662,21.1536885 69.1669662,44.7198348 C75.794917,37.1051328 70.4463322,26.8453748 81.058456,17.1725913 C81.058456,39.3863344 102.155357,38.1365645 94.0121919,69.2249916 C97.7866664,66.9118477 100.501055,63.103682 102.155357,57.8004944 C105.491398,63.103682 104.245257,72.5297487 98.416934,86.0786945 C103.547554,83.9150474 106.558165,80.9232746 108.378132,76.7271327 C109.04106,105.964869 89.5062156,126.366871 61.9867103,125.995028 C34.467205,125.623185 13.5784967,101.642443 18.2649214,71.802957 C18.9624768,74.9072731 21.5182769,78.5533566 25.1832626,80.0729101 C18.6891247,50.7321037 30.922502,49.6337285 36.0056643,33.9730813 C35.1796585,42.297059 36.0056643,46.924952 40.0208236,51.7593505 C40.7309276,49.6474958 42.0145668,47.6388953 43.3724725,45.627895 L43.7620351,45.0531669 C43.8271552,44.9573376 43.892336,44.86148 43.9575234,44.7655828 L44.5429346,43.9011285 C47.3268507,39.7628977 49.8240593,35.4880393 47.7482658,30.1694988 C44.3690672,21.5114095 44.6913719,18.1446262 52.8683497,7.99450751 Z M43.4168797,15.6028981 C41.2434833,17.8205255 41.7153274,24.275166 44.213695,29.9427578 C46.7120625,35.6103495 43.4168797,39.8756006 39.8854597,45.126676 C40.5019929,38.1390602 39.8587244,36.4802473 36.8588412,31.1077941 C33.858958,25.7353408 37.9685715,18.6230687 43.4168797,15.6028981 Z M64.7721431,8.03208837 C69.8550649,12.4485247 71.6576876,12.8901943 72.209291,17.4374541 C72.7608943,21.9847139 70.2967086,24.09635 71.2822168,30.0346208 C60.9002329,21.508497 69.0471936,18.4710785 64.7721431,8.03208837 Z M53.3587168,1.6350624e-05 C57.0113944,4.33013045 59.1813933,3.19675313 61.5638477,8.73089813 C63.9463021,14.2650431 60.9615342,15.5202483 63,22.1753596 C51.0029851,11.8529541 58.4461322,11.0173257 53.3587168,1.6350624e-05 Z" id="Combined-Shape-Copy" fill="#C84F46" />
</g>
</svg>
</template>
Expand Down
30 changes: 15 additions & 15 deletions tests/__snapshots__/pagefind.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ snapshot[`Pagefind plugin 3`] = `
{
content: "Uint8Array()",
data: {
basename: "en_8a7583c",
basename: "en_575e232",
content: "Uint8Array()",
page: [
"src",
"data",
],
url: "/pagefind/index/en_8a7583c.pf_index",
url: "/pagefind/index/en_575e232.pf_index",
},
src: {
asset: true,
Expand All @@ -171,10 +171,10 @@ snapshot[`Pagefind plugin 3`] = `
},
},
{
content: '{"version":"1.1.0","languages":{"en":{"hash":"en_2315aa1937","wasm":"en","page_count":2}}}',
content: '{"version":"1.1.0","languages":{"en":{"hash":"en_24c4def8a2","wasm":"en","page_count":2}}}',
data: {
basename: "pagefind-entry",
content: '{"version":"1.1.0","languages":{"en":{"hash":"en_2315aa1937","wasm":"en","page_count":2}}}',
content: '{"version":"1.1.0","languages":{"en":{"hash":"en_24c4def8a2","wasm":"en","page_count":2}}}',
page: [
"src",
"data",
Expand Down Expand Up @@ -2873,7 +2873,7 @@ mark.js/dist/mark.js:
"src",
"data",
],
url: "/pagefind/pagefind.en_2315aa1937.pf_meta",
url: "/pagefind/pagefind.en_24c4def8a2.pf_meta",
},
src: {
asset: true,
Expand Down Expand Up @@ -2954,20 +2954,20 @@ mark.js/dist/mark.js:
},
{
content: \`<!DOCTYPE html>
<html lang="en"><head>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>First page</title>
<link rel="stylesheet" href="/pagefind/pagefind-ui.css"><script type="text/javascript" src="/pagefind/pagefind-ui.js"></script><script type="text/javascript">window.addEventListener('DOMContentLoaded',()=>{new PagefindUI({"element":"#search","showImages":false,"excerptLength":0,"showEmptyFilters":true,"showSubResults":false,"resetStyles":true,"bundlePath":"/pagefind/","baseUrl":"/"});});</script></head>
<link href="/pagefind/pagefind-ui.css" rel="stylesheet"><script src="/pagefind/pagefind-ui.js" type="text/javascript"></script><script type="text/javascript">window.addEventListener('DOMContentLoaded',()=>{new PagefindUI({"element":"#search","showImages":false,"excerptLength":0,"showEmptyFilters":true,"showSubResults":false,"resetStyles":true,"bundlePath":"/pagefind/","baseUrl":"/"});});</script></head>
<body>
<div id="search"></div>
<h1>Hello world</h1>
<p>This is the first page</p>



</body></html>\`,
</body>
</html>\`,
data: {
basename: "index",
children: "<h1>Hello world</h1>
Expand Down Expand Up @@ -3001,20 +3001,20 @@ This is the first page
},
{
content: \`<!DOCTYPE html>
<html lang="en"><head>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Second page</title>
<link rel="stylesheet" href="/pagefind/pagefind-ui.css"><script type="text/javascript" src="/pagefind/pagefind-ui.js"></script><script type="text/javascript">window.addEventListener('DOMContentLoaded',()=>{new PagefindUI({"element":"#search","showImages":false,"excerptLength":0,"showEmptyFilters":true,"showSubResults":false,"resetStyles":true,"bundlePath":"/pagefind/","baseUrl":"/"});});</script></head>
<link href="/pagefind/pagefind-ui.css" rel="stylesheet"><script src="/pagefind/pagefind-ui.js" type="text/javascript"></script><script type="text/javascript">window.addEventListener('DOMContentLoaded',()=>{new PagefindUI({"element":"#search","showImages":false,"excerptLength":0,"showEmptyFilters":true,"showSubResults":false,"resetStyles":true,"bundlePath":"/pagefind/","baseUrl":"/"});});</script></head>
<body>
<div id="search"></div>
<h1>Other page</h1>
<p>This is the second page</p>



</body></html>\`,
</body>
</html>\`,
data: {
basename: "page2",
children: "<h1>Other page</h1>
Expand Down
1 change: 0 additions & 1 deletion tests/pagefind.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import pagefind from "../plugins/pagefind.ts";

Deno.test(
"Pagefind plugin",
{ ignore: Deno.build.os !== "darwin" },
async (t) => {
const site = getSite({
src: "pagefind",
Expand Down