File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
src/__tests__/__snapshots__ Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,15 @@ findCodeView(selector?: string): CodeViewWrapper | null;
3636 * @returns {Array<CodeViewWrapper>}
3737 */
3838findAllCodeViews(selector ? : string ): Array <CodeViewWrapper >;
39+
40+ /**
41+ * Returns the wrapper of the closest parent CodeView for the current element,
42+ * or the element itself if it is an instance of CodeView.
43+ * If no CodeView is found, returns \`null\`.
44+ *
45+ * @returns {CodeViewWrapper | null}
46+ */
47+ findClosestCodeView(): CodeViewWrapper | null ;
3948 }
4049}
4150
@@ -54,6 +63,11 @@ ElementWrapper.prototype.findAllCodeViews = function(selector) {
5463 return this .findAllComponents (CodeViewWrapper , selector );
5564} ;
5665
66+ ElementWrapper.prototype.findClosestCodeView = function() {
67+ // casting to 'any' is needed to avoid this issue with generics
68+ // https://github.com/microsoft/TypeScript/issues/29132
69+ return (this as any ).findClosestComponent (CodeViewWrapper );
70+ } ;
5771
5872export default function wrapper(root: Element = document.body) {
5973 if (document && document .body && ! document .body .contains (root )) {
You can’t perform that action at this time.
0 commit comments