WorkerDOM supports most of DOM API transparently, but due to multi-threaded
environment, 100% support is not feasible. The @ampproject/worker-dom-linter
Babel plugin validates and reports APIs that are not implemented or implemented
differently in WorkerDOM.
See WorkerDOM project for context.
Using npm:
npm install --save-dev @ampproject/worker-dom-linter
or using yarn:
yarn add @ampproject/worker-dom-linter --dev
Modify your .babelrc:
{
"plugins": [
["@ampproject/worker-dom-linter", {}]
]
}
This babel plugins doesn't have the complete typing information and thus cannot
ascertain whether a x.offsetWidth
expression references offsetWidth
property
of an HTMLElement
instance or some unrelated object. Such false positives
can be ignored by adding /*OK*/
comment, e.g. x./*OK*/offsetWidth
.