|
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:
1002 bytes
|
| Line | |
|---|
| 1 | let Declaration = require('../declaration')
|
|---|
| 2 |
|
|---|
| 3 | class WritingMode extends Declaration {
|
|---|
| 4 | insert(decl, prefix, prefixes) {
|
|---|
| 5 | if (prefix === '-ms-') {
|
|---|
| 6 | let cloned = this.set(this.clone(decl), prefix)
|
|---|
| 7 |
|
|---|
| 8 | if (this.needCascade(decl)) {
|
|---|
| 9 | cloned.raws.before = this.calcBefore(prefixes, decl, prefix)
|
|---|
| 10 | }
|
|---|
| 11 | let direction = 'ltr'
|
|---|
| 12 |
|
|---|
| 13 | decl.parent.nodes.forEach(i => {
|
|---|
| 14 | if (i.prop === 'direction') {
|
|---|
| 15 | if (i.value === 'rtl' || i.value === 'ltr') direction = i.value
|
|---|
| 16 | }
|
|---|
| 17 | })
|
|---|
| 18 |
|
|---|
| 19 | cloned.value = WritingMode.msValues[direction][decl.value] || decl.value
|
|---|
| 20 | return decl.parent.insertBefore(decl, cloned)
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | return super.insert(decl, prefix, prefixes)
|
|---|
| 24 | }
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | WritingMode.names = ['writing-mode']
|
|---|
| 28 |
|
|---|
| 29 | WritingMode.msValues = {
|
|---|
| 30 | ltr: {
|
|---|
| 31 | 'horizontal-tb': 'lr-tb',
|
|---|
| 32 | 'vertical-lr': 'tb-lr',
|
|---|
| 33 | 'vertical-rl': 'tb-rl'
|
|---|
| 34 | },
|
|---|
| 35 | rtl: {
|
|---|
| 36 | 'horizontal-tb': 'rl-tb',
|
|---|
| 37 | 'vertical-lr': 'bt-lr',
|
|---|
| 38 | 'vertical-rl': 'bt-rl'
|
|---|
| 39 | }
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | module.exports = WritingMode
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.