Merge CodeHost.codeViewSpecs and CodeHost.codeViewSpecResolver into one CodeHost.findCodeViews() function
Created by: felixfbecker
The two ways currently add complexity in handling both. This complexity will add up when we support more kinds of code view specs (e.g. for diffs).
In addition, they are less powerful, because codeViewResolver
only allows a single selector.
On the other hand there is not much gained from letting the caller run resolver.resolveCodeViewSpec(querySelectorAll(resolver.selector))
instead of just letting the resolver (a single findCodeViews()
function) run querySelectorAll()
and return ResolvedCodeView[]
found.
We could also get rid of the different ResolvedCodeView
and CodeView
types, there would only be the resolved version.
It currently makes it impossible to express a code view that is found by a selector targeting one of its children, which is what the single file blob view on GitHub and Phabricator needs to do.
Interface
findCodeViews: (container: HTMLElement) => ResolvedCodeView[]
Alternative that was considered: Having a CodeView.find()
method, but it is useful to have one function that can search for a common selector and then determine the kind of code view for each result (e.g. GitHub .file
selector)