Skip to content

Commit 558d0fe

Browse files
committed
fix: use only "var" in detecting CSS variable
1 parent 0b33f3a commit 558d0fe

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

src/block-components/columns/style.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const addStyles = ( blockStyleGenerator, props = {} ) => {
3333
responsive: 'all',
3434
valueCallback: value => {
3535
// Substitute with using format to work with preset controls
36-
if ( value.startsWith( 'var(--stk' ) ) {
36+
if ( value.startsWith( 'var' ) ) {
3737
return value
3838
}
3939
return value + 'px'
@@ -46,7 +46,7 @@ export const addStyles = ( blockStyleGenerator, props = {} ) => {
4646
attrName: 'columnGap',
4747
responsive: 'all',
4848
valueCallback: value => {
49-
if ( value.startsWith( 'var(--stk' ) ) {
49+
if ( value.startsWith( 'var' ) ) {
5050
return value
5151
}
5252
return value + 'px'
@@ -91,7 +91,7 @@ export const addStyles = ( blockStyleGenerator, props = {} ) => {
9191
attrName: 'rowGap',
9292
responsive: 'all',
9393
valueCallback: value => {
94-
if ( value.startsWith( 'var(--stk' ) ) {
94+
if ( value.startsWith( 'var' ) ) {
9595
return value
9696
}
9797
return value + 'px'
@@ -104,7 +104,7 @@ export const addStyles = ( blockStyleGenerator, props = {} ) => {
104104
attrName: 'rowGap',
105105
responsive: 'all',
106106
valueCallback: value => {
107-
if ( value.startsWith( 'var(--stk' ) ) {
107+
if ( value.startsWith( 'var' ) ) {
108108
return value
109109
}
110110
return value + 'px'

src/block-components/helpers/borders/style.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const addBorderStyles = ( blockStyleGenerator, props = {} ) => {
3939
valueCallback: value => {
4040
// Substitute with using format to work with preset controls
4141
value = typeof value === 'number' ? value.toString() : value
42-
if ( value.startsWith( 'var(--stk' ) ) {
42+
if ( value.startsWith( 'var' ) ) {
4343
return value
4444
}
4545
return value + 'px'
@@ -57,7 +57,7 @@ export const addBorderStyles = ( blockStyleGenerator, props = {} ) => {
5757
attrNameTemplate,
5858
valueCallback: value => {
5959
value = typeof value === 'number' ? value.toString() : value
60-
if ( value.startsWith( 'var(--stk' ) ) {
60+
if ( value.startsWith( 'var' ) ) {
6161
return value
6262
}
6363
return value + 'px'
@@ -75,7 +75,7 @@ export const addBorderStyles = ( blockStyleGenerator, props = {} ) => {
7575
attrNameTemplate,
7676
valueCallback: value => {
7777
value = typeof value === 'number' ? value.toString() : value
78-
if ( value.startsWith( 'var(--stk' ) ) {
78+
if ( value.startsWith( 'var' ) ) {
7979
return value
8080
}
8181
return value + 'px'
@@ -93,7 +93,7 @@ export const addBorderStyles = ( blockStyleGenerator, props = {} ) => {
9393
attrNameTemplate,
9494
valueCallback: value => {
9595
value = typeof value === 'number' ? value.toString() : value
96-
if ( value.startsWith( 'var(--stk' ) ) {
96+
if ( value.startsWith( 'var' ) ) {
9797
return value
9898
}
9999
return value + 'px'

src/components/advanced-range-control/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ export default memo( AdvancedRangeControl, isEqual )
283283
const extractNumberAndUnit = value => {
284284
// Match the last characters that are not numbers.
285285
const matches = value.match( /([\d.]+)(\D*)$/ )
286-
if ( ! matches || value.startsWith( 'var(--stk' ) ) {
286+
if ( ! matches || value.startsWith( 'var' ) ) {
287287
return [ value, '' ]
288288
}
289289
return [ matches[ 1 ], matches[ 2 ] ]

src/components/block-css/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ const BlockCss = props => {
183183

184184
if ( unit ) { // Note: this will only work for non-objects.
185185
// If the value is `auto` or a CSS variable, don't add units.
186-
if ( ! ( value === 'auto' || ( typeof value === 'string' && value.startsWith( 'var(--stk' ) ) ) ) {
186+
if ( ! ( value === 'auto' || ( typeof value === 'string' && value.startsWith( 'var' ) ) ) ) {
187187
value = `${ value }${ unit }`
188188
}
189189
}

src/components/four-range-control/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const isEqualInitial = ( props, value, firstValue ) => {
5959
const extractNumberAndUnit = value => {
6060
// Match the last characters that are not numbers.
6161
const matches = value.match( /([\d.]+)(\D*)$/ )
62-
if ( ! matches || value.startsWith( 'var(--stk' ) ) {
62+
if ( ! matches || value.startsWith( 'var' ) ) {
6363
return [ value, '' ]
6464
}
6565
return [ matches[ 1 ], matches[ 2 ] ]

src/util/styles/style-object.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ class StyleObject {
336336

337337
if ( unit ) { // Note: this will only work for non-objects.
338338
// If the value is `auto` or a CSS variable, don't add units.
339-
if ( ! ( value === 'auto' || ( typeof value === 'string' && value.startsWith( 'var(--stk' ) ) ) ) {
339+
if ( ! ( value === 'auto' || ( typeof value === 'string' && value.startsWith( 'var' ) ) ) ) {
340340
value = `${ value }${ unit }`
341341
}
342342
}

0 commit comments

Comments
 (0)