Skip to content

Commit

Permalink
Merge pull request #7 from quatico-solutions/jwloka/issue5
Browse files Browse the repository at this point in the history
t Provides tests to show that srializer reveals root element with map-contents true
  • Loading branch information
jwloka authored Aug 17, 2024
2 parents d7d0b1e + 8f05dd9 commit 680a499
Show file tree
Hide file tree
Showing 12 changed files with 545 additions and 276 deletions.
7 changes: 7 additions & 0 deletions Release-Notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ Release notes follow the [keep a changelog](https://keepachangelog.com/en/1.0.0/
- Improvement :gift_heart:: TBD
- Bugfix :pill:: TBD

## [0.6.3]- 2024-08-17

### Changed

- Improvement :gift_heart:: Use new `shadowrootmode` attribute for declarative shadow roots
- Bugfix :pill:: Fixes an issue where root elements are filtered when 'map-contents' is used for slotted elements

## [0.6.2] - 2024-05-29

Bugfix release to address installation issues with preinstall scripts.
Expand Down
1 change: 1 addition & 0 deletions src/InternalRenderOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ import { RenderOptions } from "./RenderOptions";

export interface InternalRenderOptions extends RenderOptions {
parentSlot?: HTMLSlotElement;
root?: boolean;
}
48 changes: 42 additions & 6 deletions src/renderAttributes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,27 @@ describe("renderAttributes", () => {
it("returns empty string with no attributes and diffable true", () => {
const target = create("div").html("<p>target</p>").root().querySelector("p") as Element;

const actual = renderAttributes(target, { indent: "", diffable: true, filterAttrs: [] } as any);
const actual = renderAttributes(target, {
indent: "",
diffable: true,
filterAttrs: [],
shadowDepth: 0,
shadowRoots: "declarative",
});

expect(actual).toMatchInlineSnapshot(`""`);
});

it("returns attributes string with single attribute and diffable true", () => {
const target = create("div").html("<p class='foo'>target</p>").root().querySelector("p") as Element;

const actual = renderAttributes(target, { indent: "", diffable: true, filterAttrs: [] } as any);
const actual = renderAttributes(target, {
indent: "",
diffable: true,
filterAttrs: [],
shadowDepth: 0,
shadowRoots: "declarative",
});

expect(actual).toMatchInlineSnapshot(`"class="foo""`);
});
Expand All @@ -30,7 +42,13 @@ describe("renderAttributes", () => {
.root()
.querySelector("p") as Element;

const actual = renderAttributes(target, { indent: "", diffable: true, filterAttrs: [] } as any);
const actual = renderAttributes(target, {
indent: "",
diffable: true,
filterAttrs: [],
shadowDepth: 0,
shadowRoots: "declarative",
});

expect(actual).toMatchInlineSnapshot(`
"
Expand All @@ -44,15 +62,27 @@ describe("renderAttributes", () => {
it("returns empty string with no attributes and diffable false", () => {
const target = create("div").html("<p>target</p>").root().querySelector("p") as Element;

const actual = renderAttributes(target, { indent: "", diffable: false, filterAttrs: [] } as any);
const actual = renderAttributes(target, {
indent: "",
diffable: false,
filterAttrs: [],
shadowDepth: 0,
shadowRoots: "declarative",
});

expect(actual).toMatchInlineSnapshot(`""`);
});

it("returns attributes string with single attribute and diffable false", () => {
const target = create("div").html("<p class='foo'>target</p>").root().querySelector("p") as Element;

const actual = renderAttributes(target, { indent: "", diffable: false, filterAttrs: [] } as any);
const actual = renderAttributes(target, {
indent: "",
diffable: false,
filterAttrs: [],
shadowDepth: 0,
shadowRoots: "declarative",
});

expect(actual).toMatchInlineSnapshot(`"class="foo""`);
});
Expand All @@ -63,7 +93,13 @@ describe("renderAttributes", () => {
.root()
.querySelector("p") as Element;

const actual = renderAttributes(target, { indent: "", diffable: false, filterAttrs: [] } as any);
const actual = renderAttributes(target, {
indent: "",
diffable: false,
filterAttrs: [],
shadowDepth: 0,
shadowRoots: "declarative",
});

expect(actual).toMatchInlineSnapshot(`"align="center" class="foo" id="bar""`);
});
Expand Down
14 changes: 12 additions & 2 deletions src/renderChildren.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ describe("renderChildren", () => {
it("returns innerHTML with element", () => {
const target = create("div").html("<p>EXPECTED</p>").root();

const actual = renderChildren(target, { indent: "" } as any);
const actual = renderChildren(target, {
indent: "",
diffable: true,
shadowDepth: 0,
shadowRoots: "declarative",
});

expect(actual).toMatchInlineSnapshot(`
"<p>
Expand All @@ -23,7 +28,12 @@ describe("renderChildren", () => {
it("returns empty string with empty tag", () => {
const target = create("div").root();

const actual = renderChildren(target, { indent: "" } as any);
const actual = renderChildren(target, {
indent: "",
diffable: true,
shadowDepth: 0,
shadowRoots: "declarative",
});

expect(actual).toBe("");
});
Expand Down
Loading

0 comments on commit 680a499

Please sign in to comment.