Skip to content

Commit e844757

Browse files
committed
2 fixes for custom ColorSpaces
Breaks the loop when the format is found. Allows format not to define a parse() method.
1 parent 3a96e39 commit e844757

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Diff for: src/parse.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export default function parse (str, options) {
108108
}
109109
else {
110110
// Custom, colorspace-specific format
111-
for (let space of ColorSpace.all) {
111+
loop: for (let space of ColorSpace.all) {
112112
for (let formatId in space.formats) {
113113
let format = space.formats[formatId];
114114

@@ -123,15 +123,15 @@ export default function parse (str, options) {
123123
// Convert to Format object
124124
format = space.getFormat(format);
125125

126-
let color = format.parse(env.str);
126+
let color = format.parse?.(env.str);
127127

128128
if (color) {
129129
if (meta) {
130130
Object.assign(meta, { format, formatId });
131131
}
132132

133133
ret = color;
134-
break;
134+
break loop;
135135
}
136136
}
137137
}

0 commit comments

Comments
 (0)