Skip to content

Commit 3e92a06

Browse files
authored
Use <icon-instance>.element, never use LabIcon.resolveElement
Honestly, I think the `LabIcon.resolveX` static methods might be the single biggest mistake I've made as a jlab developer. I at least should have named them ``` LabIcon.__XXX___DO_NOT_TOUCH__PRETTY_PLEASE_resolveX` ``` Less dramatically, the `.ResolveX` methods exist to cover an edge case that occurs in several places in core where instead of a full `LabIcon` instace all you may have instead is just the icon's name string. Your usage of `.resolveElement` probably isn't actively harmful here, but it is an anti-pattern. It's very slow, and (in my opinion) harder to read, in comparison to the standard `<icon-instance>.element` invocation I changed it to
1 parent cb52d5d commit 3e92a06

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/unfold.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ export class FileTreeRenderer extends DirListing.Renderer {
151151
'jp-DirListing-itemIcon'
152152
);
153153

154-
LabIcon.resolveElement({
155-
icon: folderOpenIcon,
154+
folderOpenIcon.element({
156155
iconClass: classes('jp-Icon'),
157156
container: iconContainer,
158157
className: 'jp-DirListing-itemIcon',

0 commit comments

Comments
 (0)