canvas-color-space icon indicating copy to clipboard operation
canvas-color-space copied to clipboard

Interfaces just for feature detection is an antipattern

Open domenic opened this issue 4 years ago • 2 comments

Interfaces are meant to represent instances of an object (in the OOP sense, bundling together data and operations on that data). They are not used for feature detection.

I suggest instead adding something like HTMLCanvasElement.supportsColorSpace("display-p3") or similar.

domenic avatar Feb 16 '21 21:02 domenic

Additionally, it is invalid WebIDL. Currently, WebIDL only allows for constant primitive types, which are "bigint, boolean and the numeric types."

weinig avatar Apr 28 '21 16:04 weinig

Ok, well, that's unfortunate: I think the ergonomics are better this way, as it matches how function feature detection is done, extending the approach there to enums.

kdashg avatar Apr 28 '21 19:04 kdashg