0.0.0 • Published 3 years ago

lib.dom-attributes v0.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

lib.dom-attributes

This project adds typings for attributes that are not reflected as DOM properties in major browsers. For attributes that are in scope and deprecated, it seeks to make that clear via documentation rather than omitting them from the generated output.

It uses microsoft/vscode-custom-data (the same source of information used for VS Code's HTML and CSS autocomplete suggestions and hover documentation).

How to Use

Motivation

Most HTML attributes are reflected as object properties in the JS DOM, but reflection for some important properties is not yet implemented in some major browsers- particularly aria attributes, which at the time of this writing, have not been implemented in Firefox yet. Some front end frameworks provide this functionality, but not all projects use frameworks.

In 2018, aria attributes were specced to be reflected in DOM properties: (issue) (spec PR) (spec: editors draft) (mdn compat data).

Once that happens, I hope that either one of VS Code's Custom Data or MDN's Browser Compat Data can be integrated into TypeScript's lib.dom generator. This has better potential for doc comments on the types, since documenting function overrides is clunky and slightly less discoverable to code authors.

But even after that happens, there will probably be lots of code lying around that uses setAttribute. Hopefully this project will help for that.

How to Build / Update

https://github.com/microsoft/vscode-custom-data#updating-web-data

cd data/
git pull
cd web-data/
yarn update-sources
yarn generate-data
cd ../..
node generate.js