Skip to content

Commit d2eeb0c

Browse files
committed
html: factor out contentful conditions in content setter
So not really factored out much at all, but eh.
1 parent 9e9ad40 commit d2eeb0c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/util/html.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,15 @@ export class Tag {
401401
}
402402

403403
set content(value) {
404-
if (
405-
this.selfClosing &&
406-
!(value === null ||
407-
value === undefined ||
408-
!value ||
409-
Array.isArray(value) && value.filter(Boolean).length === 0)
410-
) {
404+
const contentful =
405+
value !== null &&
406+
value !== undefined &&
407+
value &&
408+
(Array.isArray(value)
409+
? !empty(value.filter(Boolean))
410+
: true);
411+
412+
if (this.selfClosing && contentful) {
411413
throw new Error(`Tag <${this.tagName}> is self-closing but got content`);
412414
}
413415

0 commit comments

Comments
 (0)