source: node_modules/autoprefixer/lib/hacks/flex.js@ 505f39a

Last change on this file since 505f39a was 2058e5c, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Working / before login

  • Property mode set to 100644
File size: 1.1 KB
Line 
1let list = require('postcss').list
2
3let Declaration = require('../declaration')
4let flexSpec = require('./flex-spec')
5
6class Flex extends Declaration {
7 /**
8 * Return property name by final spec
9 */
10 normalize() {
11 return 'flex'
12 }
13
14 /**
15 * Change property name for 2009 spec
16 */
17 prefixed(prop, prefix) {
18 let spec
19 ;[spec, prefix] = flexSpec(prefix)
20 if (spec === 2009) {
21 return prefix + 'box-flex'
22 }
23 return super.prefixed(prop, prefix)
24 }
25
26 /**
27 * Spec 2009 supports only first argument
28 * Spec 2012 disallows unitless basis
29 */
30 set(decl, prefix) {
31 let spec = flexSpec(prefix)[0]
32 if (spec === 2009) {
33 decl.value = list.space(decl.value)[0]
34 decl.value = Flex.oldValues[decl.value] || decl.value
35 return super.set(decl, prefix)
36 }
37 if (spec === 2012) {
38 let components = list.space(decl.value)
39 if (components.length === 3 && components[2] === '0') {
40 decl.value = components.slice(0, 2).concat('0px').join(' ')
41 }
42 }
43 return super.set(decl, prefix)
44 }
45}
46
47Flex.names = ['flex', 'box-flex']
48
49Flex.oldValues = {
50 auto: '1',
51 none: '0'
52}
53
54module.exports = Flex
Note: See TracBrowser for help on using the repository browser.