Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add optional chaining in the event CSS is null #472

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defaults.display_space = sRGB;

let supportsNone;

if (typeof CSS !== "undefined" && CSS.supports) {
if (typeof CSS !== "undefined" && CSS?.supports) {
// Find widest supported color space for CSS
for (let space of [Lab, REC2020, P3]) {
let coords = space.getMinCoords();
Expand Down Expand Up @@ -42,7 +42,7 @@ if (typeof CSS !== "undefined" && CSS.supports) {
export default function display (color, {space = defaults.display_space, ...options} = {}) {
let ret = serialize(color, options);

if (typeof CSS === "undefined" || CSS.supports("color", ret) || !defaults.display_space) {
if (typeof CSS === "undefined" || CSS?.supports("color", ret) || !defaults.display_space) {
ret = new String(ret);
ret.color = color;
}
Expand Down