Skip to content

Commit

Permalink
test(deno): add runtime_tests/deno/deno.json in order to allow `docum…
Browse files Browse the repository at this point in the history
…ent`, `Element`, etc.
  • Loading branch information
usualoma committed Jan 15, 2024
1 parent 41e533d commit caba00e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- run: env NAME=Deno deno test --allow-read --allow-env runtime_tests/deno
- run: env NAME=Deno deno test --allow-read --allow-env -c runtime_tests/deno/deno.json runtime_tests/deno
- run: deno test -c runtime_tests/deno-jsx/deno.precompile.json runtime_tests/deno-jsx
- run: deno test -c runtime_tests/deno-jsx/deno.react-jsx.json runtime_tests/deno-jsx

Expand Down
4 changes: 0 additions & 4 deletions deno_dist/helper/css/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,10 @@ export const createCssContext = ({ id }: { id: Readonly<string> }) => {
}

const addClassNameToContext: HtmlEscapedCallback = ({ context, phase }) => {
/* eslint-disable @typescript-eslint/ban-ts-comment */
if (phase === HtmlEscapedCallbackPhase.BeforeDom) {
// @ts-ignore XXX: "document" is required `"lib": ["dom"]` in tsconfig, but user may not use it
const styleSheets = document.styleSheets
for (let i = 0; i < styleSheets.length; i++) {
const sheet = styleSheets[i]
// @ts-ignore XXX: "Element" is required `"lib": ["dom"]` in tsconfig, but user may not use it
if ((sheet.ownerNode as Element)?.id === id) {
if (!sheet.cssRules?.[0]?.cssText?.includes(thisSelector)) {
sheet.insertRule(`.${thisSelector}{${thisStyleString}}`)
Expand All @@ -232,7 +229,6 @@ export const createCssContext = ({ id }: { id: Readonly<string> }) => {
}
return
}
/* eslint-enable @typescript-eslint/ban-ts-comment */

if (!contextMap.get(context)) {
contextMap.set(context, [{}, {}])
Expand Down
3 changes: 2 additions & 1 deletion runtime_tests/deno-jsx/deno.precompile.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"jsx": "precompile",
"jsxImportSource": "hono/jsx"
"jsxImportSource": "hono/jsx",
"lib": ["deno.ns", "dom"]
},
"imports": {
"hono/jsx/jsx-runtime": "../../deno_dist/jsx/jsx-runtime.ts",
Expand Down
3 changes: 2 additions & 1 deletion runtime_tests/deno-jsx/deno.react-jsx.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx"
"jsxImportSource": "hono/jsx",
"lib": ["deno.ns", "dom"]
},
"imports": {
"hono/jsx/jsx-runtime": "../../deno_dist/jsx/jsx-runtime.ts",
Expand Down
5 changes: 5 additions & 0 deletions runtime_tests/deno/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"lib": ["deno.ns", "dom"]
}
}
4 changes: 0 additions & 4 deletions src/helper/css/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,10 @@ export const createCssContext = ({ id }: { id: Readonly<string> }) => {
}

const addClassNameToContext: HtmlEscapedCallback = ({ context, phase }) => {
/* eslint-disable @typescript-eslint/ban-ts-comment */
if (phase === HtmlEscapedCallbackPhase.BeforeDom) {
// @ts-ignore XXX: "document" is required `"lib": ["dom"]` in tsconfig, but user may not use it
const styleSheets = document.styleSheets
for (let i = 0; i < styleSheets.length; i++) {
const sheet = styleSheets[i]
// @ts-ignore XXX: "Element" is required `"lib": ["dom"]` in tsconfig, but user may not use it
if ((sheet.ownerNode as Element)?.id === id) {
if (!sheet.cssRules?.[0]?.cssText?.includes(thisSelector)) {
sheet.insertRule(`.${thisSelector}{${thisStyleString}}`)
Expand All @@ -232,7 +229,6 @@ export const createCssContext = ({ id }: { id: Readonly<string> }) => {
}
return
}
/* eslint-enable @typescript-eslint/ban-ts-comment */

if (!contextMap.get(context)) {
contextMap.set(context, [{}, {}])
Expand Down

0 comments on commit caba00e

Please sign in to comment.