Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lit-html] Provide directive exports via async-directive #3003

Merged
merged 7 commits into from Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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