Repository navigation
perf(icon): skip the registry lookup for names nothing can resolve (#DS-5798) - #2256
Open
nazirgitwork wants to merge 2 commits into
Open
nazirgitwork wants to merge 2 commits into
nazirgitwork wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
KbqIconasksKbqIconRegistryfor an inline SVG on every name it gets, including the plain font icons(
kbq-plus_16) that most apps never register. For such a namegetNamedSvgIconreturnsthrowError(...),so every font icon on the page built an
Error(with its stack trace) only to fall back to the font class.The icon now checks whether the registry can resolve the name before subscribing, and skips the lookup
when it cannot.
List of notable changes
KbqIconRegistry.canResolve(name)(@docs-private):truefor inline markup, a name registered withaddSvgIcon*, any name when a resolver is provided, and any name in a namespace that has an icon set.These are the same branches
getNamedSvgIcontakes, sofalsemeans the lookup could only error.KbqIcon.resolveSvgIconrenders the font class right away whencanResolveisfalse.canResolve(empty registry, named and namespaced icons, icon sets, inline markup, resolvers)and a
KbqIconspec checking that an unregistered font icon never callsgetNamedSvgIcon.canResolvemember.What should reviewers focus on
canResolvemust match the branches ofgetNamedSvgIcon. If a new way to resolve icons is added laterwithout updating
canResolve, icons it could resolve will silently render as font icons.truewithout calling the resolver or fetchingthe sprite), so behaviour there is unchanged: a miss still errors and falls back to the font class.
canResolveis public but hidden from the docs with@docs-private, sinceKbqIconlives in the sameentry point; it could be
@internalinstead if you prefer to keep it out of the typings.