import { makeMap } from './makeMap' // On the client we only need to offer special cases for boolean attributes that // have different names from their corresponding dom properties: // - itemscope -> N/A // - allowfullscreen -> allowFullscreen // - formnovalidate -> formNoValidate // - ismap -> isMap // - nomodule -> noModule // - novalidate -> noValidate // - readonly -> readOnly const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly` export const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs) // The full list is needed during SSR to produce the correct initial markup. export const isBooleanAttr = /*#__PURE__*/ makeMap( specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,ismap,` + `loop,nomodule,open,required,reversed,scoped,seamless,` + `checked,muted,multiple,selected` ) const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/ const attrValidationCache: Record = {} export function isSSRSafeAttrName(name: string): boolean { if (attrValidationCache.hasOwnProperty(name)) { return attrValidationCache[name] } const isUnsafe = unsafeAttrCharRE.test(name) if (isUnsafe) { console.error(`unsafe attribute name: ${name}`) } return (attrValidationCache[name] = !isUnsafe) } export const propsToAttrMap: Record = { acceptCharset: 'accept-charset', className: 'class', htmlFor: 'for', httpEquiv: 'http-equiv' } // CSS properties that accept plain numbers export const isNoUnitNumericStyleProp = /*#__PURE__*/ makeMap( `animation-iteration-count,border-image-outset,border-image-slice,` + `border-image-width,box-flex,box-flex-group,box-ordinal-group,column-count,` + `columns,flex,flex-grow,flex-positive,flex-shrink,flex-negative,flex-order,` + `grid-row,grid-row-end,grid-row-span,grid-row-start,grid-column,` + `grid-column-end,grid-column-span,grid-column-start,font-weight,line-clamp,` + `line-height,opacity,order,orphans,tab-size,widows,z-index,zoom,` + // SVG `fill-opacity,flood-opacity,stop-opacity,stroke-dasharray,stroke-dashoffset,` + `stroke-miterlimit,stroke-opacity,stroke-width` )