-
Notifications
You must be signed in to change notification settings - Fork 106
feat(core): slot controller ssr hint attributes #2893
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
Merged
Merged
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
d5c27c2
chore: nvm use lts
bennypowers ba4408c
chore: bump lit-labs/ssr
bennypowers cd54b8b
chore: bump lit/context
bennypowers 1bddaa9
fix: update context usage for ssr
bennypowers ed2a4c9
fix: use lit-ssr html function
bennypowers 0088148
fix(core): rely on lit's dom-shim
bennypowers 837f66a
chore: update and align lit version
bennypowers a127114
fix(core): ssr connected callback
bennypowers 1fffb2c
fix(elements): ssr connected callbacks
bennypowers 9bd0874
fix(elements): table th role from context instead of dom
bennypowers d605a41
feat(core): wip slots decorator
bennypowers 49c3202
fix(core): empty array check
bennypowers 0b3dffa
fix(core): remove need for static decorator for ssr slot hints
bennypowers 98313ce
fix(core): client-side slot controller doens't use isServer
bennypowers 9f5ecaa
fix(core): ssr-hint-has-default-slotted attr name
bennypowers 35a459e
Merge branch 'main' into feat/slot-controller-ssr
bennypowers 444d4e8
test: ssr demos
bennypowers cf9eec6
chore: ssr dev packages
bennypowers 09ca48b
Merge branch 'main' into feat/slot-controller-ssr
bennypowers 7e61848
chore: deps
bennypowers 0d9f978
docs: build elements
bennypowers f4a6dd9
docs: format
bennypowers 848a2d6
chore: revert ssr
bennypowers 81ed882
style: lint
bennypowers cdacbf0
docs: remove preloads
bennypowers eca6a80
docs: changeset
bennypowers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import type { ReactiveElement } from 'lit'; | ||
| import { | ||
| type SlotControllerArgs, | ||
| type SlotControllerPublicAPI, | ||
| } from './slot-controller.js'; | ||
|
|
||
| export class SlotController implements SlotControllerPublicAPI { | ||
| public static default = Symbol('default slot') satisfies symbol as symbol; | ||
|
|
||
| /** @deprecated use `default` */ | ||
| public static anonymous: symbol = this.default; | ||
|
|
||
| static attribute = 'ssr-hint-has-slotted' as const; | ||
|
|
||
| static anonymousAttribute = 'ssr-hint-has-slotted-default' as const; | ||
|
|
||
| constructor(public host: ReactiveElement, ..._: SlotControllerArgs) { | ||
| host.addController(this); | ||
| } | ||
|
|
||
| hostConnected?(): Promise<void>; | ||
|
|
||
| private fromAttribute(slots: string | null) { | ||
| return (slots ?? '') | ||
| .split(/[, ]/) | ||
| .map(x => x.trim()); | ||
| } | ||
|
|
||
| getSlotted<T extends Element = Element>(..._: string[]): T[] { | ||
| return []; | ||
| } | ||
|
|
||
| hasSlotted(...names: (string | null)[]): boolean { | ||
| const attr = this.host.getAttribute(SlotController.attribute); | ||
| const anon = this.host.hasAttribute(SlotController.anonymousAttribute); | ||
| const hints = new Set(this.fromAttribute(attr)); | ||
| return names.every(x => x === null ? anon : hints.has(x)); | ||
| } | ||
|
|
||
| isEmpty(...names: (string | null)[]): boolean { | ||
| return !this.hasSlotted(...names); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| module.exports = { | ||
| templateEngineOverride: 'njk', | ||
| permalink: '{{ demo.permalink }}', | ||
| pagination: { | ||
| data: 'demos', | ||
| alias: 'demo', | ||
| size: 1, | ||
| before: xs => xs.filter(x => x.permalink), | ||
| }, | ||
| preloads: [ | ||
| '@lit/reactive-element@1.0.2/development/css-tag.js', | ||
| '@lit/reactive-element@1.0.2/development/decorators/base.js', | ||
| '@lit/reactive-element@1.0.2/development/decorators/custom-element.js', | ||
| '@lit/reactive-element@1.0.2/development/decorators/event-options.js', | ||
| '@lit/reactive-element@1.0.2/development/decorators/property.js', | ||
| '@lit/reactive-element@1.0.2/development/decorators/query-all.js', | ||
| '@lit/reactive-element@1.0.2/development/decorators/query-assigned-nodes.js', | ||
| '@lit/reactive-element@1.0.2/development/decorators/query-async.js', | ||
| '@lit/reactive-element@1.0.2/development/decorators/query.js', | ||
| '@lit/reactive-element@1.0.2/development/decorators/state.js', | ||
| '@lit/reactive-element@1.0.2/development/reactive-element.js', | ||
| 'lit-element@3.0.2/development/experimental-hydrate-support.js', | ||
| 'lit-element@3.0.2/development/lit-element.js', | ||
| 'lit-html@2.0.2/_/a39ea7cf.js', | ||
| 'lit-html@2.0.2/development/async-directive.js', | ||
| 'lit-html@2.0.2/development/directive-helpers.js', | ||
| 'lit-html@2.0.2/development/directive.js', | ||
| 'lit-html@2.0.2/development/directives/guard.js', | ||
| 'lit-html@2.0.2/development/directives/if-defined.js', | ||
| 'lit-html@2.0.2/development/directives/live.js', | ||
| 'lit-html@2.0.2/development/directives/ref.js', | ||
| 'lit-html@2.0.2/development/directives/repeat.js', | ||
| 'lit-html@2.0.2/development/directives/style-map.js', | ||
| 'lit-html@2.0.2/development/directives/template-content.js', | ||
| 'lit-html@2.0.2/development/directives/unsafe-html.js', | ||
| 'lit-html@2.0.2/development/directives/unsafe-svg.js', | ||
| 'lit-html@2.0.2/development/directives/until.js', | ||
| 'lit-html@2.0.2/development/experimental-hydrate.js', | ||
| 'lit-html@2.0.2/development/lit-html.js', | ||
| 'lit-html@2.0.2/development/static.js', | ||
| 'lit@2.0.2/async-directive.js', | ||
| 'lit@2.0.2/decorators.js', | ||
| 'lit@2.0.2/decorators/query-all.js', | ||
| 'lit@2.0.2/decorators/query-assigned-nodes.js', | ||
| 'lit@2.0.2/decorators/query-async.js', | ||
| 'lit@2.0.2/decorators/query.js', | ||
| 'lit@2.0.2/directives/guard.js', | ||
| 'lit@2.0.2/directives/if-defined.js', | ||
| 'lit@2.0.2/directives/live.js', | ||
| 'lit@2.0.2/directives/ref.js', | ||
| 'lit@2.0.2/directives/repeat.js', | ||
| 'lit@2.0.2/directives/style-map.js', | ||
| 'lit@2.0.2/directives/template-content.js', | ||
| 'lit@2.0.2/directives/unsafe-html.js', | ||
| 'lit@2.0.2/directives/unsafe-svg.js', | ||
| 'lit@2.0.2/directives/until.js', | ||
| 'lit@2.0.2/experimental-hydrate-support.js', | ||
| 'lit@2.0.2/experimental-hydrate.js', | ||
| 'lit@2.0.2/html.js', | ||
| 'lit@2.0.2/index.js', | ||
| 'lit@2.0.2/polyfill-support.js', | ||
| 'lit@2.0.2/static-html.js', | ||
| ], | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.