|
Last change
on this file since 2058e5c was 2058e5c, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Working / before login
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | let list = require('postcss').list
|
|---|
| 2 |
|
|---|
| 3 | let Declaration = require('../declaration')
|
|---|
| 4 | let flexSpec = require('./flex-spec')
|
|---|
| 5 |
|
|---|
| 6 | class 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 |
|
|---|
| 47 | Flex.names = ['flex', 'box-flex']
|
|---|
| 48 |
|
|---|
| 49 | Flex.oldValues = {
|
|---|
| 50 | auto: '1',
|
|---|
| 51 | none: '0'
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | module.exports = Flex
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.