JS API

diagnostics

The warnings produced by the last render. Nothing in the language is a fatal error, so this is where problems show up.

Syntax

  • doodle.diagnostics

An array of { message, pos } objects, where pos is the [column, line] of the source when known. Each new warning is also dispatched as a warn event; preventDefault() keeps it out of the console. Reported situations include an unknown function called with arguments, an unclosed parenthesis, a @keyframes without a name, and a @use variable that includes itself.

Examples

const doodle = document.querySelector('css-doodle');

doodle.update(`
  @grid: 5 / 60vmin;
  background: @colour(red, blue);
`);

console.log(doodle.diagnostics);
// [{ message: 'unknown function @colour()', pos: [...] }]

See also