|
Last change
on this file was 2058e5c, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Working / before login
|
-
Property mode
set to
100644
|
|
File size:
1.3 KB
|
| Rev | Line | |
|---|
| [2058e5c] | 1 | let OldValue = require('../old-value')
|
|---|
| 2 | let Value = require('../value')
|
|---|
| 3 | let flexSpec = require('./flex-spec')
|
|---|
| 4 |
|
|---|
| 5 | class DisplayFlex extends Value {
|
|---|
| 6 | constructor(name, prefixes) {
|
|---|
| 7 | super(name, prefixes)
|
|---|
| 8 | if (name === 'display-flex') {
|
|---|
| 9 | this.name = 'flex'
|
|---|
| 10 | }
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | /**
|
|---|
| 14 | * Faster check for flex value
|
|---|
| 15 | */
|
|---|
| 16 | check(decl) {
|
|---|
| 17 | return decl.prop === 'display' && decl.value === this.name
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | /**
|
|---|
| 21 | * Change value for old specs
|
|---|
| 22 | */
|
|---|
| 23 | old(prefix) {
|
|---|
| 24 | let prefixed = this.prefixed(prefix)
|
|---|
| 25 | if (!prefixed) return undefined
|
|---|
| 26 | return new OldValue(this.name, prefixed)
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | /**
|
|---|
| 30 | * Return value by spec
|
|---|
| 31 | */
|
|---|
| 32 | prefixed(prefix) {
|
|---|
| 33 | let spec, value
|
|---|
| 34 | ;[spec, prefix] = flexSpec(prefix)
|
|---|
| 35 |
|
|---|
| 36 | if (spec === 2009) {
|
|---|
| 37 | if (this.name === 'flex') {
|
|---|
| 38 | value = 'box'
|
|---|
| 39 | } else {
|
|---|
| 40 | value = 'inline-box'
|
|---|
| 41 | }
|
|---|
| 42 | } else if (spec === 2012) {
|
|---|
| 43 | if (this.name === 'flex') {
|
|---|
| 44 | value = 'flexbox'
|
|---|
| 45 | } else {
|
|---|
| 46 | value = 'inline-flexbox'
|
|---|
| 47 | }
|
|---|
| 48 | } else if (spec === 'final') {
|
|---|
| 49 | value = this.name
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | return prefix + value
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | /**
|
|---|
| 56 | * Add prefix to value depend on flebox spec version
|
|---|
| 57 | */
|
|---|
| 58 | replace(string, prefix) {
|
|---|
| 59 | return this.prefixed(prefix)
|
|---|
| 60 | }
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | DisplayFlex.names = ['display-flex', 'inline-flex']
|
|---|
| 64 |
|
|---|
| 65 | module.exports = DisplayFlex
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.