Skip to content

Commit

Permalink
[lit-html] Provide directive exports via async-directive (#3003)
Browse files Browse the repository at this point in the history
[lit-html] Provide directive exports via async-directive. Fixes #2790. This is being done for convenience.
  • Loading branch information
Steve Orvell committed Jul 25, 2022
1 parent 1ac5805 commit daddeb3
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .changeset/curly-cars-peel.md
@@ -0,0 +1,6 @@
---
'lit-html': patch
'lit': patch
---

Lit's `async-directive` now re-exports everything from the `directive` module.
2 changes: 1 addition & 1 deletion packages/labs/cli/src/lib/generate/generate.ts
Expand Up @@ -35,7 +35,7 @@ interface GenerateCommand extends Omit<ResolvedCommand, 'run'> {

const frameworkCommands = {
react: reactCommand,
vue: vueCommand
vue: vueCommand,
};

type FrameworkName = keyof typeof frameworkCommands;
Expand Down
6 changes: 3 additions & 3 deletions packages/labs/context/src/lib/controllers/context-provider.ts
Expand Up @@ -56,11 +56,11 @@ export class ContextProvider<T extends ContextKey<unknown, unknown>>
public onContextRequest = (
ev: ContextRequestEvent<ContextKey<unknown, unknown>>
): void => {
// Only call the callback if the context matches.
// Also, in case an element is a consumer AND a provider
// Only call the callback if the context matches.
// Also, in case an element is a consumer AND a provider
// of the same context, we want to avoid the element to self-register.
// The check on composedPath (as opposed to ev.target) is to cover cases
// where the consumer is in the shadowDom of the provider (in which case,
// where the consumer is in the shadowDom of the provider (in which case,
// event.target === this.host because of event retargeting).
if (ev.context !== this.context || ev.composedPath()[0] === this.host) {
return;
Expand Down
2 changes: 1 addition & 1 deletion packages/lit-html/src/async-directive.ts
Expand Up @@ -121,7 +121,7 @@
import {AttributePart, ChildPart, Disconnectable, Part} from './lit-html.js';
import {isSingleExpression} from './directive-helpers.js';
import {Directive, PartInfo, PartType} from './directive.js';
export {directive} from './directive.js';
export * from './directive.js';

const DEV_MODE = true;

Expand Down
7 changes: 5 additions & 2 deletions packages/lit-html/src/directives/async-replace.ts
Expand Up @@ -5,8 +5,11 @@
*/

import {ChildPart, noChange} from '../lit-html.js';
import {directive, DirectiveParameters} from '../directive.js';
import {AsyncDirective} from '../async-directive.js';
import {
AsyncDirective,
directive,
DirectiveParameters,
} from '../async-directive.js';
import {Pauser, PseudoWeakRef, forAwaitOf} from './private-async-helpers.js';

type Mapper<T> = (v: T, index?: number) => unknown;
Expand Down
3 changes: 1 addition & 2 deletions packages/lit-html/src/directives/until.ts
Expand Up @@ -5,9 +5,8 @@
*/

import {Part, noChange} from '../lit-html.js';
import {directive} from '../directive.js';
import {isPrimitive} from '../directive-helpers.js';
import {AsyncDirective} from '../async-directive.js';
import {directive, AsyncDirective} from '../async-directive.js';
import {Pauser, PseudoWeakRef} from './private-async-helpers.js';

const isPromise = (x: unknown) => {
Expand Down
7 changes: 5 additions & 2 deletions packages/lit-html/src/test/directive-helpers_test.ts
Expand Up @@ -4,7 +4,6 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
import {html, ChildPart, render, svg} from 'lit-html';
import {directive, Directive} from 'lit-html/directive.js';
import {assert} from '@esm-bundle/chai';
import {stripExpressionComments} from './test-utils/strip-markers.js';
import {
Expand All @@ -18,7 +17,11 @@ import {
TemplateResultType,
} from 'lit-html/directive-helpers.js';
import {classMap} from 'lit-html/directives/class-map.js';
import {AsyncDirective} from 'lit-html/async-directive.js';
import {
directive,
Directive,
AsyncDirective,
} from 'lit-html/async-directive.js';

suite('directive-helpers', () => {
let container: HTMLDivElement;
Expand Down

0 comments on commit daddeb3

Please sign in to comment.