Skip to content

Commit e8794d4

Browse files
authored
Merge pull request #42 from open-wc/fix/default-slot
fix: default slot name handling
2 parents b0c530b + a43354e commit e8794d4

File tree

9 files changed

+21
-25
lines changed

9 files changed

+21
-25
lines changed

packages/analyzer/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ customElements.define('my-element', MyElement);
326326
*
327327
* @csspart bar - Styles the color of bar
328328
*
329+
* @slot - This is a default/unnamed slot
329330
* @slot container - You can put some elements here
330331
*
331332
* @cssprop --text-color - Controls the color of foo

packages/analyzer/browser/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/analyzer/custom-elements.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,14 @@
1010
"kind": "class",
1111
"description": "",
1212
"name": "MyElement",
13-
"members": [
13+
"slots": [
1414
{
15-
"kind": "method",
16-
"name": "myMethod"
17-
}
18-
],
19-
"events": [
15+
"description": "- foo slot",
16+
"name": "foo"
17+
},
2018
{
21-
"type": {
22-
"text": "MyCustomEvent"
23-
}
19+
"description": "description is this",
20+
"name": ""
2421
}
2522
],
2623
"superclass": {
Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11

2-
import { LitElement } from 'lit';
3-
42
/**
5-
* Some information here.
3+
* @slot foo - foo slot
4+
* @slot - description is this
65
*/
7-
class MyCustomEvent extends CustomEvent {
8-
constructor(eventInit) {
9-
super('my-custom-event', eventInit);
10-
}
11-
}
12-
136
export class MyElement extends LitElement {
14-
myMethod() {
15-
// FAILS HERE because no `type` argument is being passed to `MyCustomEvent`.
16-
this.dispatchEvent(new MyCustomEvent());
17-
}
187
}

packages/analyzer/fixtures/class-jsdoc/fixture/custom-elements.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
}
2929
],
3030
"slots": [
31+
{
32+
"description": "This is the default slot",
33+
"name": ""
34+
},
3135
{
3236
"description": "- You can put some elements here",
3337
"name": "container"

packages/analyzer/fixtures/class-jsdoc/output.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
}
2929
],
3030
"slots": [
31+
{
32+
"description": "This is the default slot",
33+
"name": ""
34+
},
3135
{
3236
"description": "- You can put some elements here",
3337
"name": "container"

packages/analyzer/fixtures/class-jsdoc/package/my-element.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*
1313
* @csspart bar - Styles the color of bar
1414
*
15+
* @slot - This is the default slot
1516
* @slot container - You can put some elements here
1617
*
1718
* @cssprop --text-color - Controls the color of foo

packages/analyzer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@custom-elements-manifest/analyzer",
3-
"version": "0.3.4",
3+
"version": "0.3.5",
44
"description": "",
55
"license": "MIT",
66
"type": "module",

packages/analyzer/src/features/analyse-phase/class-jsdoc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function handleClassJsDoc(doc, tag) {
129129
}
130130

131131
if(tag?.name) {
132-
doc.name = tag.name;
132+
doc.name = tag.name === '-' ? '' : tag.name;
133133
}
134134

135135
if(tag?.default) {

0 commit comments

Comments
 (0)