Skip to content

Commit 7a8abf5

Browse files
driskullbenelan
authored andcommitted
refactor: remove deprecated utilities and functions (#10471)
**Related Issue:** #6059 ## Summary - remove `getSlotted()` util and tests - remove `ConditionalSlotComponent` utility file. - remove `getElementProp()` util. Unused. - depends on removal of `pick-list` and `value-list` components.
1 parent 7e7cc03 commit 7a8abf5

File tree

3 files changed

+0
-438
lines changed

3 files changed

+0
-438
lines changed

packages/calcite-components/src/utils/conditionalSlot.ts

Lines changed: 0 additions & 59 deletions
This file was deleted.

packages/calcite-components/src/utils/dom.spec.ts

Lines changed: 0 additions & 264 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ import { guidPattern } from "./guid.spec";
88
import {
99
ensureId,
1010
focusElementInGroup,
11-
getElementProp,
1211
getModeName,
1312
getShadowRootNode,
1413
getSlotAssignedElements,
15-
getSlotted,
1614
isBefore,
1715
isKeyboardTriggeredClick,
1816
isPrimaryPointerButton,
@@ -30,268 +28,6 @@ import {
3028
} from "./dom";
3129

3230
describe("dom", () => {
33-
describe("getElementProp()", () => {
34-
describe("light DOM", () => {
35-
it("returns match if found on self", async () => {
36-
document.body.innerHTML = `
37-
<div>
38-
<div>
39-
<div id="test" test-prop="self"></div>
40-
</div>
41-
</div>
42-
`;
43-
44-
expect(getElementProp(document.getElementById("test"), "test-prop", "not-found")).toBe("self");
45-
});
46-
47-
it("returns first ancestral match", async () => {
48-
document.body.innerHTML = `
49-
<div test-prop="root">
50-
<div>
51-
<div id="test" ></div>
52-
</div>
53-
</div>
54-
`;
55-
56-
expect(getElementProp(document.getElementById("test"), "test-prop", "not-found")).toBe("root");
57-
});
58-
59-
it("returns fallback if no match is found", async () => {
60-
document.body.innerHTML = `
61-
<div>
62-
<div>
63-
<div id="test"></div>
64-
</div>
65-
</div>
66-
`;
67-
68-
expect(getElementProp(document.getElementById("test"), "test-prop", "not-found")).toBe("not-found");
69-
});
70-
});
71-
72-
describe("shadow DOM boundaries", () => {
73-
function defineTestComponents(): void {
74-
class PropLookupParentTest extends HTMLElement {
75-
constructor() {
76-
super();
77-
this.attachShadow({ mode: "open" });
78-
}
79-
80-
connectedCallback(): void {
81-
this.shadowRoot.innerHTML = `<prop-lookup-child-test></prop-lookup-child-test>`;
82-
}
83-
}
84-
85-
class PropLookupChildTest extends HTMLElement {
86-
constructor() {
87-
super();
88-
this.attachShadow({ mode: "open" });
89-
}
90-
91-
connectedCallback(): void {
92-
this.shadowRoot.innerHTML = "<div>😄</div>";
93-
}
94-
}
95-
96-
customElements.define("prop-lookup-parent-test", PropLookupParentTest);
97-
customElements.define("prop-lookup-child-test", PropLookupChildTest);
98-
}
99-
100-
beforeEach(defineTestComponents);
101-
102-
it("does not cross shadow DOM boundary (default)", () => {
103-
document.body.innerHTML = `
104-
<prop-lookup-parent-test id="test" test-prop="parent"></prop-lookup-parent-test>
105-
`;
106-
107-
expect(
108-
getElementProp(document.getElementById("test").shadowRoot.firstElementChild, "test-prop", "not-found"),
109-
).toBe("not-found");
110-
});
111-
});
112-
});
113-
114-
describe("getSlotted()", () => {
115-
const testSlotName = "test";
116-
const testSlotName2 = "test2";
117-
118-
function getTestComponent(): HTMLElement {
119-
return document.body.querySelector("slot-test");
120-
}
121-
122-
function defineTestComponents() {
123-
class SlotTest extends HTMLElement {
124-
constructor() {
125-
super();
126-
this.attachShadow({ mode: "open" });
127-
}
128-
129-
connectedCallback(): void {
130-
this.shadowRoot.innerHTML = html`
131-
<slot name="${testSlotName}"></slot>
132-
<slot name="${testSlotName2}"></slot>
133-
<slot></slot>
134-
`;
135-
}
136-
}
137-
138-
customElements.define("slot-test", SlotTest);
139-
}
140-
141-
beforeEach(() => {
142-
defineTestComponents();
143-
144-
document.body.innerHTML = `
145-
<slot-test>
146-
<h2 slot=${testSlotName}>
147-
<span>😃</span>
148-
<span>🙂</span>
149-
</h2>
150-
<h2 slot=${testSlotName}><span>😂</span></h2>
151-
<h3 slot=${testSlotName2}><span>😂</span></h3>
152-
<div id="default-slot-el"><p>🙂</p></div>
153-
</slot-test>
154-
`;
155-
});
156-
157-
describe("single slotted", () => {
158-
it("returns elements with matching default slot", () => expect(getSlotted(getTestComponent())).toBeTruthy());
159-
160-
it("returns elements with matching slot name", () =>
161-
expect(getSlotted(getTestComponent(), testSlotName)).toBeTruthy());
162-
163-
it("returns elements with matching slot names", () =>
164-
expect(getSlotted(getTestComponent(), [testSlotName, testSlotName2])).toBeTruthy());
165-
166-
it("returns null when no results", () => expect(getSlotted(getTestComponent(), "non-existent-slot")).toBeNull());
167-
168-
describe("scoped selector", () => {
169-
it("returns element with matching default slot", () =>
170-
expect(getSlotted(getTestComponent(), { selector: "p" })).toBeTruthy());
171-
172-
it("returns element with matching nested selector", () =>
173-
expect(getSlotted(getTestComponent(), testSlotName, { selector: "span" })).toBeTruthy());
174-
175-
it("returns nothing with non-matching child selector", () =>
176-
expect(
177-
getSlotted(getTestComponent(), testSlotName, {
178-
selector: "non-existent-slot",
179-
}),
180-
).toBeNull());
181-
});
182-
183-
describe("direct slotted children", () => {
184-
it("returns element if slot is child of element", () => {
185-
document.body.innerHTML = `
186-
<slot-test>
187-
<h2 slot=${testSlotName}><span>😂</span></h2>
188-
<some-other-element>
189-
<h2 slot=${testSlotName}><span>🙃</span></h2>
190-
</some-other-element>
191-
</slot-test>
192-
`;
193-
194-
expect(
195-
getSlotted(getTestComponent(), testSlotName, {
196-
direct: true,
197-
}),
198-
).toBeTruthy();
199-
});
200-
201-
it("returns null if slot is nested", () => {
202-
document.body.innerHTML = `
203-
<slot-test>
204-
<some-other-element>
205-
<h2 slot=${testSlotName}><span>🙃</span></h2>
206-
</some-other-element>
207-
</slot-test>
208-
`;
209-
210-
expect(
211-
getSlotted(getTestComponent(), testSlotName, {
212-
all: true,
213-
direct: true,
214-
}),
215-
).toBeTruthy();
216-
});
217-
});
218-
});
219-
220-
describe("multiple slotted", () => {
221-
it("returns element with default slot name", () =>
222-
expect(getSlotted(getTestComponent(), { all: true })).toHaveLength(1));
223-
224-
it("returns elements with matching slot name", () =>
225-
expect(getSlotted(getTestComponent(), testSlotName, { all: true })).toHaveLength(2));
226-
227-
it("returns elements with matching slot names", () =>
228-
expect(
229-
getSlotted(getTestComponent(), [testSlotName, testSlotName2], {
230-
all: true,
231-
}),
232-
).toHaveLength(3));
233-
234-
it("returns empty list when no results", () =>
235-
expect(getSlotted(getTestComponent(), "non-existent-slot", { all: true })).toHaveLength(0));
236-
237-
describe("scoped selector", () => {
238-
it("returns child elements matching selector", () =>
239-
expect(
240-
getSlotted(getTestComponent(), testSlotName, {
241-
all: true,
242-
selector: "span",
243-
}),
244-
).toHaveLength(3));
245-
246-
it("returns empty list with non-matching child selector", () =>
247-
expect(
248-
getSlotted(getTestComponent(), testSlotName, {
249-
all: true,
250-
selector: "non-existent",
251-
}),
252-
).toHaveLength(0));
253-
});
254-
255-
describe("direct slotted children", () => {
256-
it("returns child elements if children are direct descendants", () => {
257-
document.body.innerHTML = `
258-
<slot-test>
259-
<h2 slot=${testSlotName}><span>😃</span></h2>
260-
<some-other-element>
261-
<h2 slot=${testSlotName}><span>🙃</span></h2>
262-
</some-other-element>
263-
</slot-test>
264-
`;
265-
266-
expect(
267-
getSlotted(getTestComponent(), testSlotName, {
268-
all: true,
269-
direct: true,
270-
}),
271-
).toHaveLength(1);
272-
});
273-
274-
it("returns empty list if children are nested", () => {
275-
document.body.innerHTML = `
276-
<slot-test>
277-
<some-other-element>
278-
<h2 slot=${testSlotName}><span>😃</span></h2>
279-
<h2 slot=${testSlotName}><span>🙃</span></h2>
280-
</some-other-element>
281-
</slot-test>
282-
`;
283-
284-
expect(
285-
getSlotted(getTestComponent(), testSlotName, {
286-
all: true,
287-
direct: true,
288-
}),
289-
).toHaveLength(0);
290-
});
291-
});
292-
});
293-
});
294-
29531
describe("setRequestedIcon()", () => {
29632
it("returns the custom icon name if custom value is passed", () =>
29733
expect(setRequestedIcon({ exampleValue: "exampleReturnedValue" }, "myCustomValue", "exampleValue")).toBe(

0 commit comments

Comments
 (0)