@@ -74,3 +74,39 @@ test('strange inbetween character attributes', function (t) {
7474 t . equal ( vdom . create ( tree ) . toString ( ) , `<div f@o="bar" b&z="qux"></div>` )
7575 t . end ( )
7676} )
77+
78+ test ( 'null and undefined attributes' , function ( t ) {
79+ var tree = hx `<div onclick="alert(1)" onmouseenter=${ undefined } onmouseleave=${ null } ></div>`
80+ t . equal ( vdom . create ( tree ) . toString ( ) , `<div onclick="alert(1)"></div>` )
81+ t . end ( )
82+ } )
83+
84+ test ( 'undefined (with quotes) attribute value is evaluated' , function ( t ) {
85+ var tree = hx `<div foo='undefined'></div>`
86+ t . equal ( vdom . create ( tree ) . toString ( ) , `<div foo="undefined"></div>` )
87+ t . end ( )
88+ } )
89+
90+ test ( 'null (with quotes) attribute value is evaluated' , function ( t ) {
91+ var tree = hx `<div foo='null'></div>`
92+ t . equal ( vdom . create ( tree ) . toString ( ) , `<div foo="null"></div>` )
93+ t . end ( )
94+ } )
95+
96+ test ( 'undefined (without quotes) attribute value is evaluated' , function ( t ) {
97+ var tree = hx `<div foo=undefined></div>`
98+ t . equal ( vdom . create ( tree ) . toString ( ) , `<div foo="undefined"></div>` )
99+ t . end ( )
100+ } )
101+
102+ test ( 'null (without quotes) attribute value is evaluated' , function ( t ) {
103+ var tree = hx `<div foo=null></div>`
104+ t . equal ( vdom . create ( tree ) . toString ( ) , `<div foo="null"></div>` )
105+ t . end ( )
106+ } )
107+
108+ test ( 'null is ignored and adjacent attribute is evaluated' , function ( t ) {
109+ var tree = hx `<div foo=${ null } t></div>`
110+ t . equal ( vdom . create ( tree ) . toString ( ) , `<div t="t"></div>` )
111+ t . end ( )
112+ } )
0 commit comments