@@ -18,7 +18,7 @@ const padding = require("./properties/padding");
18
18
19
19
const borderImageProperty = "border-image" ;
20
20
21
- exports . shorthandProperties = new Map ( [
21
+ const shorthandProperties = new Map ( [
22
22
[ "background" , background ] ,
23
23
[
24
24
"border" ,
@@ -45,7 +45,7 @@ exports.shorthandProperties = new Map([
45
45
[ "padding" , padding ]
46
46
] ) ;
47
47
48
- exports . borderProperties = new Set ( [
48
+ const borderProperties = new Set ( [
49
49
"border" ,
50
50
borderImageProperty ,
51
51
...border . shorthandFor . keys ( ) ,
@@ -56,7 +56,7 @@ exports.borderProperties = new Set([
56
56
...borderLeft . shorthandFor . keys ( )
57
57
] ) ;
58
58
59
- exports . getPositionValue = ( positionValues , position ) => {
59
+ const getPositionValue = ( positionValues , position ) => {
60
60
switch ( positionValues . length ) {
61
61
case 1 : {
62
62
const [ val1 ] = positionValues ;
@@ -351,7 +351,7 @@ const replacePositionValue = (value, positionValues, position) => {
351
351
}
352
352
} ;
353
353
354
- exports . prepareBorderProperties = ( property , value , priority , properties , opt = { } ) => {
354
+ const prepareBorderProperties = ( property , value , priority , properties , opt = { } ) => {
355
355
if ( typeof property !== "string" || value === null ) {
356
356
return ;
357
357
}
@@ -796,7 +796,7 @@ exports.prepareBorderProperties = (property, value, priority, properties, opt =
796
796
if ( ! borderItems . has ( name ) ) {
797
797
return ;
798
798
}
799
- const borderProperties = new Map ( [ [ name , borderItems . get ( name ) ] ] ) ;
799
+ const borderProps = new Map ( [ [ name , borderItems . get ( name ) ] ] ) ;
800
800
for ( const line of lines ) {
801
801
const lineProperty = `${ name } -${ line } ` ;
802
802
const lineItem = borderItems . get ( lineProperty ) ??
@@ -805,7 +805,7 @@ exports.prepareBorderProperties = (property, value, priority, properties, opt =
805
805
value : "" ,
806
806
priority : ""
807
807
} ;
808
- borderProperties . set ( lineProperty , lineItem ) ;
808
+ borderProps . set ( lineProperty , lineItem ) ;
809
809
}
810
810
for ( const position of positions ) {
811
811
const positionProperty = `${ name } -${ position } ` ;
@@ -815,7 +815,7 @@ exports.prepareBorderProperties = (property, value, priority, properties, opt =
815
815
value : "" ,
816
816
priority : ""
817
817
} ;
818
- borderProperties . set ( positionProperty , positionItem ) ;
818
+ borderProps . set ( positionProperty , positionItem ) ;
819
819
for ( const line of lines ) {
820
820
const longhandProperty = `${ name } -${ position } -${ line } ` ;
821
821
const longhandItem = borderItems . get ( longhandProperty ) ??
@@ -824,16 +824,16 @@ exports.prepareBorderProperties = (property, value, priority, properties, opt =
824
824
value : "" ,
825
825
priority : ""
826
826
} ;
827
- borderProperties . set ( longhandProperty , longhandItem ) ;
827
+ borderProps . set ( longhandProperty , longhandItem ) ;
828
828
}
829
829
}
830
830
const borderImageItem = borderItems . get ( borderImageProperty ) ?? {
831
831
property : borderImageProperty ,
832
832
value : "" ,
833
833
priority : ""
834
834
} ;
835
- borderProperties . set ( borderImageProperty , borderImageItem ) ;
836
- return borderProperties ;
835
+ borderProps . set ( borderImageProperty , borderImageItem ) ;
836
+ return borderProps ;
837
837
} ;
838
838
839
839
const generateBorderLineShorthand = ( items , property , prior ) => {
@@ -842,7 +842,7 @@ const generateBorderLineShorthand = (items, property, prior) => {
842
842
const { value : itemValue } = item ;
843
843
values . push ( itemValue ) ;
844
844
}
845
- const value = exports . getPositionValue ( values ) ;
845
+ const value = getPositionValue ( values ) ;
846
846
const priority = prior ? prior : "" ;
847
847
return [ property , { property, value, priority } ] ;
848
848
} ;
@@ -1149,7 +1149,7 @@ const prepareBorderShorthands = (properties) => {
1149
1149
return properties ;
1150
1150
} ;
1151
1151
1152
- exports . prepareProperties = ( properties , opt = { } ) => {
1152
+ const prepareProperties = ( properties , opt = { } ) => {
1153
1153
const { globalObject, options } = opt ;
1154
1154
const parseOpt = {
1155
1155
globalObject,
@@ -1158,13 +1158,13 @@ exports.prepareProperties = (properties, opt = {}) => {
1158
1158
const { positions } = borderElements ;
1159
1159
const parsedProperties = new Map ( ) ;
1160
1160
const prepareShorthands = new Map ( ) ;
1161
- const borderProperties = new Map ( ) ;
1161
+ const borderProps = new Map ( ) ;
1162
1162
for ( const [ property , item ] of properties ) {
1163
1163
const { value, priority } = item ;
1164
1164
const { logicalPropertyGroup : shorthandProperty } = implementedProperties . get ( property ) ?? { } ;
1165
- if ( exports . borderProperties . has ( property ) ) {
1166
- borderProperties . set ( property , { property, value, priority } ) ;
1167
- } else if ( exports . shorthandProperties . has ( shorthandProperty ) ) {
1165
+ if ( borderProperties . has ( property ) ) {
1166
+ borderProps . set ( property , { property, value, priority } ) ;
1167
+ } else if ( shorthandProperties . has ( shorthandProperty ) ) {
1168
1168
if ( ! prepareShorthands . has ( shorthandProperty ) ) {
1169
1169
prepareShorthands . set ( shorthandProperty , new Map ( ) ) ;
1170
1170
}
@@ -1183,8 +1183,8 @@ exports.prepareProperties = (properties, opt = {}) => {
1183
1183
prepareShorthands . set ( shorthandProperty , longhandItems ) ;
1184
1184
}
1185
1185
parsedProperties . set ( property , item ) ;
1186
- } else if ( exports . shorthandProperties . has ( property ) ) {
1187
- const shorthandItem = exports . shorthandProperties . get ( property ) ;
1186
+ } else if ( shorthandProperties . has ( property ) ) {
1187
+ const shorthandItem = shorthandProperties . get ( property ) ;
1188
1188
const parsedValues = shorthandItem . parse ( value , parseOpt ) ;
1189
1189
let omitShorthandProperty = false ;
1190
1190
if ( Array . isArray ( parsedValues ) ) {
@@ -1199,7 +1199,7 @@ exports.prepareProperties = (properties, opt = {}) => {
1199
1199
}
1200
1200
}
1201
1201
const { position } = longhandItem ;
1202
- const longhandValue = exports . getPositionValue ( [ parsedValue ] , position ) ;
1202
+ const longhandValue = getPositionValue ( [ parsedValue ] , position ) ;
1203
1203
parsedProperties . set ( longhandProperty , {
1204
1204
property : longhandProperty ,
1205
1205
value : longhandValue ,
@@ -1235,7 +1235,7 @@ exports.prepareProperties = (properties, opt = {}) => {
1235
1235
}
1236
1236
if ( prepareShorthands . size ) {
1237
1237
for ( const [ property , item ] of prepareShorthands ) {
1238
- const shorthandItem = exports . shorthandProperties . get ( property ) ;
1238
+ const shorthandItem = shorthandProperties . get ( property ) ;
1239
1239
if ( item . size === shorthandItem . shorthandFor . size ) {
1240
1240
if ( shorthandItem . position ) {
1241
1241
const positionValues = [ ] ;
@@ -1246,7 +1246,7 @@ exports.prepareProperties = (properties, opt = {}) => {
1246
1246
priority = longhandPriority ;
1247
1247
}
1248
1248
}
1249
- const value = exports . getPositionValue ( positionValues , shorthandItem . position ) ;
1249
+ const value = getPositionValue ( positionValues , shorthandItem . position ) ;
1250
1250
parsedProperties . set ( property , {
1251
1251
property,
1252
1252
value,
@@ -1256,10 +1256,10 @@ exports.prepareProperties = (properties, opt = {}) => {
1256
1256
}
1257
1257
}
1258
1258
}
1259
- if ( borderProperties . size ) {
1259
+ if ( borderProps . size ) {
1260
1260
const longhandProperties = new Map ( ) ;
1261
- for ( const [ property , item ] of borderProperties ) {
1262
- if ( exports . shorthandProperties . has ( property ) ) {
1261
+ for ( const [ property , item ] of borderProps ) {
1262
+ if ( shorthandProperties . has ( property ) ) {
1263
1263
const { value, priority } = item ;
1264
1264
if ( property === "border" ) {
1265
1265
const lineItems = border . parse ( value , parseOpt ) ;
@@ -1297,13 +1297,13 @@ exports.prepareProperties = (properties, opt = {}) => {
1297
1297
} ) ;
1298
1298
}
1299
1299
} else {
1300
- const shorthandItem = exports . shorthandProperties . get ( property ) ;
1300
+ const shorthandItem = shorthandProperties . get ( property ) ;
1301
1301
const parsedItem = shorthandItem . parse ( value , parseOpt ) ;
1302
1302
if ( Array . isArray ( parsedItem ) ) {
1303
1303
const [ namePart , linePart ] = property . split ( "-" ) ;
1304
1304
for ( const position of positions ) {
1305
1305
const longhandProperty = `${ namePart } -${ position } -${ linePart } ` ;
1306
- const longhandValue = exports . getPositionValue ( parsedItem , position ) ;
1306
+ const longhandValue = getPositionValue ( parsedItem , position ) ;
1307
1307
const longhandItem = {
1308
1308
property : longhandProperty ,
1309
1309
value : longhandValue ,
@@ -1362,7 +1362,7 @@ exports.prepareProperties = (properties, opt = {}) => {
1362
1362
return parsedProperties ;
1363
1363
} ;
1364
1364
1365
- exports . normalizeBorderProperties = ( properties ) => {
1365
+ const normalizeProperties = ( properties ) => {
1366
1366
const { lines, name, positions } = borderElements ;
1367
1367
if ( properties . has ( name ) ) {
1368
1368
for ( const line of lines ) {
@@ -1406,3 +1406,12 @@ exports.normalizeBorderProperties = (properties) => {
1406
1406
}
1407
1407
return properties ;
1408
1408
} ;
1409
+
1410
+ module . exports = {
1411
+ borderProperties,
1412
+ getPositionValue,
1413
+ normalizeProperties,
1414
+ prepareBorderProperties,
1415
+ prepareProperties,
1416
+ shorthandProperties
1417
+ } ;
0 commit comments