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: inputfiles/README.md
+40-1Lines changed: 40 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,45 @@ Some files in this directory are generated. Please do not edit them.
4
4
This specifically includes:
5
5
6
6
*`idl/*`
7
-
*`mdn/*`
7
+
*`mdn.json`
8
8
9
9
Feel free to send a pull request with changes to any other files.
10
+
Note It is recommended to add your patch use KDL format, continue reading to find out more.
11
+
12
+
## Patches
13
+
14
+
The `patches/` directory contains `.kdl` files that specify modifications ("patches") on top of the Web IDL from web specifications, using the [KDL format](https://kdl.dev/).
15
+
These patches are applied by [`patches.ts`](../src/build/patches.ts).
16
+
17
+
### When to add a patch
18
+
19
+
- Add extra types to the generated types, e.g. type parameters.
20
+
- Make types more strict, e.g. replacing a string type into a string literal type.
21
+
- Remove features that are not widely supported by web browsers, in case it's not automatically removed.
22
+
23
+
### When not to add a patch
24
+
25
+
- When the type is incorrect, and that's from an upstream spec. It's recommended to file a bug in the corresponding spec, and when the fix happens, it will be applied here automatically.
26
+
27
+
### How to write a patch
28
+
29
+
- Try to add a new patch file when the newly desired patch is big, e.g. as long as a whole page. If it's just a few lines then it can usually go into one of the existing files.
30
+
- Files are named per their originating web specification. https://respec.org/xref/ helps you search the specifications. If there's no existing patch with that name, you should add one even if the patch will be very small.
31
+
- Please add code comment about the intent for the patch, e.g. a feature is removed as it's only implemented in one browser.
32
+
- You can largely follow the Web IDL structure but in KDL syntax:
33
+
- Most top level types e.g. `enum`, `interface`, or `dictionary` have the same names, but multi-word names like `interface mixin` are hyphened as `interface-mixin`.
34
+
- Attributes and operations are called `property` and `method` respectively to follow TypeScript convention.
35
+
- If in doubt, feel free to file an issue or request help in [Discord dom-lib-generator channel](https://discord.gg/kRYw84uG).
36
+
37
+
#### Example (`patches/touch-events.kdl`)
38
+
39
+
```kdl
40
+
interface-mixin GlobalEventHandlers {
41
+
// Touch event handlers are intentionally hidden in non-mobile web browsers.
42
+
// See w3c.github.io/touch-events#dfn-expose-legacy-touch-event-apis.
0 commit comments