-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathdeprecated.js
More file actions
44 lines (36 loc) · 1.06 KB
/
deprecated.js
File metadata and controls
44 lines (36 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { getAttrNameFunction } from '~stackable/util'
export const deprecatedAddAttributes = ( attrObject, attrNameTemplate = '%s' ) => {
attrObject.add( {
attributes: {
height: {
stkResponsive: true,
stkUnits: 'px',
type: 'number',
default: '',
},
},
attrNameTemplate,
versionAdded: '3.0.0',
versionDeprecated: '3.16.0',
} )
}
export const deprecateSizeControlHeight = {
isEligible: attrNameTemplate => attributes => {
const getAttrName = getAttrNameFunction( attrNameTemplate )
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
const height = getAttribute( 'height' )
return typeof height === 'number'
},
migrate: attrNameTemplate => attributes => {
const getAttrName = getAttrNameFunction( attrNameTemplate )
const getAttribute = _attrName => attributes[ getAttrName( _attrName ) ]
const newAttributes = {
...attributes,
}
const height = getAttribute( 'height' )
if ( typeof height === 'number' ) {
newAttributes[ getAttrName( 'height' ) ] = String( height )
}
return newAttributes
},
}