You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+98Lines changed: 98 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,104 @@ evolution of the schema. The schema follows [semver](https://semver.org/) versio
41
41
42
42
This version will not always match the npm package version, as some changes to the npm package might not have changes to the schema. We will publish a list of schema versions and their associated npm versions and git tags.
43
43
44
+
## Example
45
+
46
+
Given the following source code in directory `my-project`:
47
+
48
+
`my-project/my-element.js`:
49
+
```js
50
+
/**
51
+
* This is the description of the class
52
+
*/
53
+
exportclassMyElementextendsHTMLElement {
54
+
staticgetobservedAttributes() {
55
+
return ['disabled'];
56
+
}
57
+
58
+
setdisabled(val) {
59
+
this.__disabled= val;
60
+
}
61
+
getdisabled() {
62
+
returnthis.__disabled;
63
+
}
64
+
65
+
fire() {
66
+
this.dispatchEvent(newEvent('disabled-changed'));
67
+
}
68
+
}
69
+
70
+
customElements.define('my-element', MyElement);
71
+
```
72
+
73
+
The manifest would look like:
74
+
75
+
`my-project/custom-elements.json`:
76
+
```json
77
+
{
78
+
"schemaVersion": "1.0.0",
79
+
"readme": "README.md",
80
+
"modules": [
81
+
{
82
+
"kind": "javascript-module",
83
+
"path": "my-project/my-element.js",
84
+
"declarations": [
85
+
{
86
+
"kind": "class",
87
+
"description": "This is the description of the class",
88
+
"name": "MyElement",
89
+
"members": [
90
+
{
91
+
"kind": "field",
92
+
"name": "disabled"
93
+
},
94
+
{
95
+
"kind": "method",
96
+
"name": "fire"
97
+
}
98
+
],
99
+
"events": [
100
+
{
101
+
"name": "disabled-changed",
102
+
"type": {
103
+
"text": "Event"
104
+
}
105
+
}
106
+
],
107
+
"attributes": [
108
+
{
109
+
"name": "disabled"
110
+
}
111
+
],
112
+
"superclass": {
113
+
"name": "HTMLElement"
114
+
},
115
+
"tagName": "my-element",
116
+
"customElement": true
117
+
}
118
+
],
119
+
"exports": [
120
+
{
121
+
"kind": "js",
122
+
"name": "MyElement",
123
+
"declaration": {
124
+
"name": "MyElement",
125
+
"module": "my-project/my-element.js"
126
+
}
127
+
},
128
+
{
129
+
"kind": "custom-element-definition",
130
+
"name": "my-element",
131
+
"declaration": {
132
+
"name": "MyElement",
133
+
"module": "my-project/my-element.js"
134
+
}
135
+
}
136
+
]
137
+
}
138
+
]
139
+
}
140
+
```
141
+
44
142
# Motivation
45
143
46
144
Many tools need some machine-readable descriptions of custom elements: IDEs, documentation viewers, linters, graphical design tools, etc.
0 commit comments