Skip to content

Commit

Permalink
[fix] TS configuration for building
Browse files Browse the repository at this point in the history
  • Loading branch information
TechQuery committed Jul 12, 2024
1 parent e0b73ce commit df2d10d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "declarative-shadow-dom-polyfill",
"version": "0.3.0",
"version": "0.3.1",
"license": "LGPL-2.1-or-later",
"author": "[email protected]",
"description": "Web standard polyfill for Declarative Shadow DOM",
Expand Down Expand Up @@ -30,7 +30,7 @@
"lint-staged": "^15.2.7",
"prettier": "^3.3.2",
"tsx": "^4.16.2",
"typedoc": "^0.26.3",
"typedoc": "^0.26.4",
"typedoc-plugin-mdn-links": "^3.2.2",
"typescript": "^5.5.3"
},
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Document.parseHTMLUnsafe()", () => {

strictEqual(outerElements.length, 1);
strictEqual(outerElements[0].tagName.toLowerCase(), "my-tag");
strictEqual(outerElements[0].shadowRoot.innerHTML.trim(), innerHTML);
strictEqual(outerElements[0].shadowRoot!.innerHTML.trim(), innerHTML);
});
});

Expand All @@ -34,25 +34,25 @@ describe(".setHTMLUnsafe()", () => {

strictEqual(outerElements.length, 1);
strictEqual(outerElements[0].tagName.toLowerCase(), "my-tag");
strictEqual(outerElements[0].shadowRoot.innerHTML.trim(), innerHTML);
strictEqual(outerElements[0].shadowRoot!.innerHTML.trim(), innerHTML);
});
});

describe(".getHTML()", () => {
it("should return `.innerHTML` value with no parameter", () => {
const { body } = document;
const myTag = body.firstElementChild;
const myTag = body.firstElementChild!;
const { shadowRoot } = myTag;

strictEqual(body.innerHTML, body.getHTML());
strictEqual(myTag.innerHTML, myTag.getHTML());
strictEqual(shadowRoot.innerHTML, shadowRoot.getHTML());
strictEqual(shadowRoot!.innerHTML, shadowRoot!.getHTML());
});

it("should return `.innerHTML` value with invalid parameters", () => {
strictEqual(
document.body.innerHTML,
document.body.getHTML({ serializableShadowRoots: true }),
document.body.getHTML({ serializableShadowRoots: true })
);

const missMatchedShadowRoot = document
Expand All @@ -63,20 +63,20 @@ describe(".getHTML()", () => {
document.body.innerHTML,
document.body.getHTML({
serializableShadowRoots: true,
shadowRoots: [missMatchedShadowRoot],
}),
shadowRoots: [missMatchedShadowRoot]
})
);
});

it("should generate a Declarative Shadow DOM string with valid parameters", () => {
const serializedHTML = document.body.getHTML({
serializableShadowRoots: true,
shadowRoots: [document.querySelector("my-tag").shadowRoot],
shadowRoots: [document.querySelector("my-tag")!.shadowRoot!]
});

strictEqual(
serializedHTML.replace(/\s/g, ""),
outerHTML.replace(/\s/g, ""),
outerHTML.replace(/\s/g, "")
);
});
});
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"sourceMap": true,
"outDir": "dist"
},
"include": ["source/**/*"],
"typedocOptions": {
"name": "Declarative Shadow DOM polyfill",
"excludeExternals": true,
Expand Down

0 comments on commit df2d10d

Please sign in to comment.