@@ -288,23 +288,27 @@ class StyleObject {
288288 const unitAttrName = getAttributeName ( `${ attrName } Unit` , device , state )
289289 const actualAttrName = getAttributeName ( attrName , device , state )
290290
291- let unit = hasUnits ? ( getAttribute ( unitAttrName , device , state , true ) || hasUnits ) : ''
291+ let unit = hasUnits ? ( attributes [ unitAttrName ] || hasUnits ) : ''
292292 let value = attributes [ actualAttrName ]
293293
294- /* Allow unspecified fontSizeUnit to be set based on the desktop/tablet
295- * unit if value for fontSize is empty. */
296- if ( ( value === '' || typeof value === 'undefined' ) && ( 0 === unitAttrName . indexOf ( 'fontSizeUnit' ) ) ) {
294+ /**
295+ * Allow unspecified units to be set based on the larger used
296+ * unitdesktop/tablet unit if value is empty. For example in `rem`,
297+ * any mobile value that's automatically applied should also show
298+ * `rem`
299+ */
300+ if ( value === '' && ( device === 'tablet' || device === 'mobile' ) ) {
297301 const desktopUnit = attributes [ getAttributeName ( `${ attrName } Unit` , 'desktop' , state ) ]
298302 const tabletUnit = attributes [ getAttributeName ( `${ attrName } Unit` , 'tablet' , state ) ]
299- const tabletValue = attributes [ getAttributeName ( attrName , 'tablet' , state ) ]
300- if ( device === 'mobile' ) {
301- if ( tabletValue !== '' && typeof tabletValue !== 'undefined' ) {
303+ if ( device === 'tablet' ) {
304+ unit = desktopUnit
305+ } else if ( device === 'mobile' ) {
306+ const tabletValue = attributes [ getAttributeName ( attrName , 'tablet' , state ) ]
307+ if ( tabletValue !== '' ) {
302308 unit = tabletUnit
303309 } else {
304310 unit = desktopUnit
305311 }
306- } else if ( device === 'tablet' ) {
307- unit = desktopUnit
308312 }
309313 }
310314
0 commit comments