File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 3
3
const Element = require ( './Element' )
4
4
5
5
function append ( el , child ) {
6
+ if ( child === false || child === null || child === undefined ) return
6
7
if ( child instanceof Element ) {
7
8
el . append ( child )
8
9
} else if ( Array . isArray ( child ) ) {
9
10
child . forEach ( c => append ( el , c ) )
10
- } else if ( child !== null && child !== undefined ) {
11
+ } else {
11
12
el . append ( String ( child ) )
12
13
}
13
14
}
Original file line number Diff line number Diff line change 3
3
const test = require ( 'ava' )
4
4
const Element = require ( '../lib/Element' )
5
5
6
- test ( 'ignore __self and __source properties' , t => {
6
+ // TODO probably better to ignore in serialization instead
7
+ test ( 'ignore __self and __source attributes' , t => {
7
8
const el = new Element ( 'foo' , {
8
9
__source : 'source' ,
9
10
__self : 'self' ,
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ const test = require ( 'ava' )
4
+ const x = require ( '../lib/x' )
5
+
6
+ test ( 'ignore false children' , t => {
7
+ const el = x ( 'foo' , { } , false )
8
+
9
+ t . is ( el . children . length , 0 )
10
+ } )
11
+
12
+ test ( 'ignore null children' , t => {
13
+ const el = x ( 'foo' , { } , null )
14
+
15
+ t . is ( el . children . length , 0 )
16
+ } )
17
+
18
+ test ( 'ignore undefined children' , t => {
19
+ const el = x ( 'foo' , { } , undefined )
20
+
21
+ t . is ( el . children . length , 0 )
22
+ } )
You can’t perform that action at this time.
0 commit comments