11/** 
2-  * @typedef  {import('../types.js ').State  } State  
3-  * @typedef  {import('../types.js ').Parents } Parents 
4-  * @typedef  {import('../types.js ').Element  } Element  
5-  *@typedef  { import('../types.js').Properties } Properties  
6-  * @typedef  {import('../types .js').PropertyValue  } PropertyValue  
2+  * @typedef  {import('hast ').Element  } Element  
3+  * @typedef  {import('hast ').Parents } Parents 
4+  * @typedef  {import('hast ').Properties  } Properties  
5+  * 
6+  * @typedef  {import('../index .js').State  } State  
77 */ 
88
99import  { ccount }  from  'ccount' 
1010import  { stringify  as  commas }  from  'comma-separated-tokens' 
11- import  { svg , find }  from  'property-information' 
11+ import  { find , svg }  from  'property-information' 
1212import  { stringify  as  spaces }  from  'space-separated-tokens' 
1313import  { stringifyEntities }  from  'stringify-entities' 
14- import  { opening }  from  '../omission/opening.js' 
1514import  { closing }  from  '../omission/closing.js' 
15+ import  { opening }  from  '../omission/opening.js' 
1616
1717/** 
1818 * Maps of subsets. 
@@ -21,7 +21,7 @@ import {closing} from '../omission/closing.js'
2121 * The value at `0` causes parse errors, the value at `1` is valid. 
2222 * Of both, the value at `0` is unsafe, and the value at `1` is safe. 
2323 * 
24-  * @type  {Record<'name ' | 'unquoted ' | 'single' | 'double ', Array<[Array<string>, Array<string>]>> } 
24+  * @type  {Record<'double ' | 'name ' | 'single' | 'unquoted ', Array<[Array<string>, Array<string>]>> } 
2525 */ 
2626const  constants  =  { 
2727 // See: <https://html.spec.whatwg.org/#attribute-name-state>. 
@@ -60,7 +60,6 @@ const constants = {
6060 * @returns  {string } 
6161 * Serialized node. 
6262 */ 
63- // eslint-disable-next-line complexity 
6463export  function  element ( node ,  index ,  parent ,  state )  { 
6564 const  schema  =  state . schema 
6665 const  omit  =  schema . space  ===  'svg'  ? false  : state . settings . omitOptionalTags 
@@ -138,7 +137,7 @@ function serializeAttributes(state, props) {
138137
139138 if  ( props )  { 
140139 for  ( key  in  props )  { 
141-  if  ( props [ key ]  !==  undefined  &&  props [ key ]  !==  null )  { 
140+  if  ( props [ key ]  !==  null  &&  props [ key ]  !==  undefined )  { 
142141 const  value  =  serializeAttribute ( state ,  key ,  props [ key ] ) 
143142 if  ( value )  values . push ( value ) 
144143 } 
@@ -148,7 +147,7 @@ function serializeAttributes(state, props) {
148147 while  ( ++ index  <  values . length )  { 
149148 const  last  =  state . settings . tightAttributes 
150149 ? values [ index ] . charAt ( values [ index ] . length  -  1 ) 
151-  : null 
150+  : undefined 
152151
153152 // In tight mode, don’t add a space after quoted attributes. 
154153 if  ( index  !==  values . length  -  1  &&  last  !==  '"'  &&  last  !==  "'" )  { 
@@ -162,10 +161,9 @@ function serializeAttributes(state, props) {
162161/** 
163162 * @param  {State } state 
164163 * @param  {string } key 
165-  * @param  {PropertyValue } value 
164+  * @param  {Properties[keyof Properties] } value 
166165 * @returns  {string } 
167166 */ 
168- // eslint-disable-next-line complexity 
169167function  serializeAttribute ( state ,  key ,  value )  { 
170168 const  info  =  find ( state . schema ,  key ) 
171169 const  x  = 
@@ -185,8 +183,8 @@ function serializeAttribute(state, key, value) {
185183 } 
186184
187185 if  ( 
188-  value  ===  undefined  || 
189186 value  ===  null  || 
187+  value  ===  undefined  || 
190188 value  ===  false  || 
191189 ( typeof  value  ===  'number'  &&  Number . isNaN ( value ) ) 
192190 )  { 
@@ -235,8 +233,8 @@ function serializeAttribute(state, key, value) {
235233 result  =  stringifyEntities ( 
236234 value , 
237235 Object . assign ( { } ,  state . settings . characterReferences ,  { 
238-  subset :  constants . unquoted [ x ] [ y ] , 
239-  attribute :  true 
236+  attribute :  true , 
237+  subset :  constants . unquoted [ x ] [ y ] 
240238 } ) 
241239 ) 
242240 } 
0 commit comments