Skip to content

Commit

Permalink
fix(shared): fixes focus-visible types in test
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamind authored and Westbrook committed Nov 8, 2019
1 parent b980f2a commit 0dc7d68
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
13 changes: 2 additions & 11 deletions packages/action-menu/test/action-menu.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import '../../menu/lib/index.js';
import '../../menu-item/lib/index.js';
import { fixture, elementUpdated, html, expect } from '@open-wc/testing';
import { waitForPredicate } from '../../../test/testing-helpers';
import { FocusVisiblePolyfillableElement } from '../../shared/lib/focus-visible.js';

describe('Action menu', () => {
it('loads', async () => {
Expand Down Expand Up @@ -48,11 +47,7 @@ describe('Action menu', () => {
`
);

await waitForPredicate(
() =>
!!((window as unknown) as FocusVisiblePolyfillableElement)
.applyFocusVisiblePolyfill
);
await waitForPredicate(() => !!window.applyFocusVisiblePolyfill);
await elementUpdated(el);

expect(el).to.not.be.undefined;
Expand Down Expand Up @@ -88,11 +83,7 @@ describe('Action menu', () => {
`
);

await waitForPredicate(
() =>
!!((window as unknown) as FocusVisiblePolyfillableElement)
.applyFocusVisiblePolyfill
);
await waitForPredicate(() => !!window.applyFocusVisiblePolyfill);
await elementUpdated(el);

expect(el).to.not.be.undefined;
Expand Down
10 changes: 8 additions & 2 deletions packages/shared/src/focus-visible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

declare global {
interface Window {
applyFocusVisiblePolyfill?: (scope: Document | ShadowRoot) => void;
}
}

type Constructor<T = object> = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
new (...args: any[]): T;
prototype: T;
};

export interface OptionalLifecycleCallbacks {
interface OptionalLifecycleCallbacks {
connectedCallback?(): void;
disconnectedCallback?(): void;
}

export type MixableBaseClass = HTMLElement & OptionalLifecycleCallbacks;
type MixableBaseClass = HTMLElement & OptionalLifecycleCallbacks;

type EndPolyfillCoordinationCallback = () => void;

Expand Down
8 changes: 1 addition & 7 deletions packages/shared/src/missing-types.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
declare module 'focus-visible' {
declare global {
interface Window {
applyFocusVisiblePolyfill?: (scope: Document | ShadowRoot) => void;
}
}
}
declare module 'focus-visible';

0 comments on commit 0dc7d68

Please sign in to comment.