Update dependencies
This commit is contained in:
parent
48e8c8a1af
commit
95d054f9b4
7555 changed files with 144369 additions and 196135 deletions
488
node_modules/rtlcss/lib/plugin.js
generated
vendored
488
node_modules/rtlcss/lib/plugin.js
generated
vendored
|
@ -1,75 +1,66 @@
|
|||
'use strict'
|
||||
|
||||
const config = require('./config.js')
|
||||
const util = require('./util.js')
|
||||
|
||||
var config = require('./config.js')
|
||||
var util = require('./util.js')
|
||||
module.exports = {
|
||||
name: 'rtlcss',
|
||||
priority: 100,
|
||||
directives: {
|
||||
control: {
|
||||
ignore: {
|
||||
expect: { atrule: true, comment: true, decl: true, rule: true },
|
||||
endNode: null,
|
||||
begin (node, metadata, context) {
|
||||
'name': 'rtlcss',
|
||||
'priority': 100,
|
||||
'directives': {
|
||||
'control': {
|
||||
'ignore': {
|
||||
'expect': { 'atrule': true, 'comment': true, 'decl': true, 'rule': true },
|
||||
'endNode': null,
|
||||
'begin': function (node, metadata, context) {
|
||||
// find the ending node in case of self closing directive
|
||||
if (!this.endNode && metadata.begin && metadata.end) {
|
||||
let n = node
|
||||
var n = node
|
||||
while (n && n.nodes) {
|
||||
n = n.nodes[n.nodes.length - 1]
|
||||
}
|
||||
|
||||
this.endNode = n
|
||||
}
|
||||
|
||||
let prevent = true
|
||||
var prevent = true
|
||||
if (node.type === 'comment' && node.text.match(/^\s*!?\s*rtl:end:ignore/)) {
|
||||
prevent = false
|
||||
}
|
||||
|
||||
return prevent
|
||||
},
|
||||
end (node, metadata, context) {
|
||||
'end': function (node, metadata, context) {
|
||||
// end if:
|
||||
// 1. block directive and the node is comment
|
||||
// 2. self closing directive and node is endNode
|
||||
if ((metadata.begin !== metadata.end && node.type === 'comment') || (metadata.begin && metadata.end && node === this.endNode)) {
|
||||
if (metadata.begin !== metadata.end && node.type === 'comment' || metadata.begin && metadata.end && node === this.endNode) {
|
||||
// clear ending node
|
||||
this.endNode = null
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
},
|
||||
rename: {
|
||||
expect: { rule: true },
|
||||
begin (node, metadata, context) {
|
||||
'rename': {
|
||||
'expect': {'rule': true},
|
||||
'begin': function (node, metadata, context) {
|
||||
node.selector = context.util.applyStringMap(node.selector, false)
|
||||
return false
|
||||
},
|
||||
end (node, context) {
|
||||
'end': function (node, context) {
|
||||
return true
|
||||
}
|
||||
},
|
||||
raw: {
|
||||
expect: { self: true },
|
||||
begin (node, metadata, context) {
|
||||
const nodes = context.postcss.parse(metadata.param, { from: node.source.input.from })
|
||||
nodes.walk((node) => {
|
||||
node[context.symbol] = true
|
||||
})
|
||||
'raw': {
|
||||
'expect': {'self': true},
|
||||
'begin': function (node, metadata, context) {
|
||||
var nodes = context.postcss.parse(metadata.param, { from: node.source.input.from })
|
||||
node.parent.insertBefore(node, nodes)
|
||||
return true
|
||||
},
|
||||
end (node, context) {
|
||||
'end': function (node, context) {
|
||||
return true
|
||||
}
|
||||
},
|
||||
remove: {
|
||||
expect: { atrule: true, rule: true, decl: true },
|
||||
begin (node, metadata, context) {
|
||||
let prevent = false
|
||||
'remove': {
|
||||
'expect': {'atrule': true, 'rule': true, 'decl': true},
|
||||
'begin': function (node, metadata, context) {
|
||||
var prevent = false
|
||||
switch (node.type) {
|
||||
case 'atrule':
|
||||
case 'rule':
|
||||
|
@ -77,245 +68,234 @@ module.exports = {
|
|||
prevent = true
|
||||
node.remove()
|
||||
}
|
||||
|
||||
return prevent
|
||||
},
|
||||
end (node, metadata, context) {
|
||||
'end': function (node, metadata, context) {
|
||||
return true
|
||||
}
|
||||
},
|
||||
options: {
|
||||
expect: { self: true },
|
||||
stack: [],
|
||||
begin (node, metadata, context) {
|
||||
'options': {
|
||||
'expect': {'self': true},
|
||||
'stack': [],
|
||||
'begin': function (node, metadata, context) {
|
||||
this.stack.push(util.extend({}, context.config))
|
||||
let options
|
||||
var options
|
||||
try {
|
||||
options = JSON.parse(metadata.param)
|
||||
} catch (e) {
|
||||
throw node.error('Invalid options object', { details: e })
|
||||
throw node.error('Invlaid options object', { 'details': e })
|
||||
}
|
||||
|
||||
context.config = config.configure(options, context.config.plugins)
|
||||
context.util = util.configure(context.config)
|
||||
return true
|
||||
},
|
||||
end (node, metadata, context) {
|
||||
const config = this.stack.pop()
|
||||
'end': function (node, metadata, context) {
|
||||
var config = this.stack.pop()
|
||||
if (config && !metadata.begin) {
|
||||
context.config = config
|
||||
context.util = util.configure(context.config)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
},
|
||||
config: {
|
||||
expect: { self: true },
|
||||
stack: [],
|
||||
begin (node, metadata, context) {
|
||||
'config': {
|
||||
'expect': {'self': true},
|
||||
'expr': {
|
||||
'fn': /function([^\(]*)\(([^\(\)]*?)\)[^\{]*\{([^]*)\}/ig,
|
||||
'rx': /\/([^\/]*)\/(.*)/ig
|
||||
},
|
||||
'stack': [],
|
||||
'begin': function (node, metadata, context) {
|
||||
this.stack.push(util.extend({}, context.config))
|
||||
let configuration
|
||||
var configuration
|
||||
try {
|
||||
configuration = eval(`(${metadata.param})`) // eslint-disable-line no-eval
|
||||
configuration = eval('(' + metadata.param + ')') // eslint-disable-line no-eval
|
||||
} catch (e) {
|
||||
throw node.error('Invalid config object', { details: e })
|
||||
throw node.error('Invlaid config object', { 'details': e })
|
||||
}
|
||||
|
||||
context.config = config.configure(configuration.options, configuration.plugins)
|
||||
context.util = util.configure(context.config)
|
||||
return true
|
||||
},
|
||||
end (node, metadata, context) {
|
||||
const config = this.stack.pop()
|
||||
'end': function (node, metadata, context) {
|
||||
var config = this.stack.pop()
|
||||
if (config && !metadata.begin) {
|
||||
context.config = config
|
||||
context.util = util.configure(context.config)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
},
|
||||
value: [
|
||||
'value': [
|
||||
{
|
||||
name: 'ignore',
|
||||
action (decl, expr, context) {
|
||||
'name': 'ignore',
|
||||
'action': function (decl, expr, context) {
|
||||
return true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'prepend',
|
||||
action (decl, expr, context) {
|
||||
let prefix = ''
|
||||
const hasRawValue = decl.raws.value && decl.raws.value.raw
|
||||
const raw = `${decl.raws.between.substr(1).trim()}${hasRawValue ? decl.raws.value.raw : decl.value}${decl.important ? decl.raws.important.substr(9).trim() : ''}`
|
||||
raw.replace(expr, (m, v) => {
|
||||
'name': 'prepend',
|
||||
'action': function (decl, expr, context) {
|
||||
var prefix = ''
|
||||
decl.raws.value.raw.replace(expr, function (m, v) {
|
||||
prefix += v
|
||||
})
|
||||
decl.value = hasRawValue
|
||||
? (decl.raws.value.raw = prefix + decl.raws.value.raw)
|
||||
: prefix + decl.value
|
||||
decl.value = decl.raws.value.raw = prefix + decl.raws.value.raw
|
||||
return true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'append',
|
||||
action (decl, expr, context) {
|
||||
let suffix = ''
|
||||
const hasRawValue = decl.raws.value && decl.raws.value.raw
|
||||
const raw = `${decl.raws.between.substr(1).trim()}${hasRawValue ? decl.raws.value.raw : decl.value}${decl.important ? decl.raws.important.substr(9).trim() : ''}`
|
||||
raw.replace(expr, (m, v) => {
|
||||
suffix = v + suffix
|
||||
'name': 'append',
|
||||
'action': function (decl, expr, context) {
|
||||
decl.value = decl.raws.value.raw = decl.raws.value.raw.replace(expr, function (match, value) {
|
||||
return match + value
|
||||
})
|
||||
decl.value = hasRawValue ? (decl.raws.value.raw += suffix) : decl.value + suffix
|
||||
return true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'insert',
|
||||
action (decl, expr, context) {
|
||||
const hasRawValue = decl.raws.value && decl.raws.value.raw
|
||||
const raw = `${decl.raws.between.substr(1).trim()}${hasRawValue ? decl.raws.value.raw : decl.value}${decl.important ? decl.raws.important.substr(9).trim() : ''}`
|
||||
const result = raw.replace(expr, (match, value) => hasRawValue ? value + match : value)
|
||||
decl.value = hasRawValue ? (decl.raws.value.raw = result) : result
|
||||
'name': 'insert',
|
||||
'action': function (decl, expr, context) {
|
||||
decl.value = decl.raws.value.raw = decl.raws.value.raw.replace(expr, function (match, value) {
|
||||
return value + match
|
||||
})
|
||||
return true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '',
|
||||
action (decl, expr, context) {
|
||||
const hasRawValue = decl.raws.value && decl.raws.value.raw
|
||||
const raw = `${decl.raws.between.substr(1).trim()}${hasRawValue ? decl.raws.value.raw : ''}${decl.important ? decl.raws.important.substr(9).trim() : ''}`
|
||||
raw.replace(expr, (match, value) => {
|
||||
decl.value = hasRawValue
|
||||
? (decl.raws.value.raw = value + match)
|
||||
: value
|
||||
'name': '',
|
||||
'action': function (decl, expr, context) {
|
||||
decl.raws.value.raw.replace(expr, function (match, value) {
|
||||
decl.value = decl.raws.value.raw = value + match
|
||||
})
|
||||
return true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
processors: [
|
||||
'processors': [
|
||||
{
|
||||
name: 'variable',
|
||||
expr: /^--/im,
|
||||
action (prop, value) {
|
||||
return { prop, value }
|
||||
'name': 'variable',
|
||||
'expr': /^--/im,
|
||||
'action': function (prop, value) {
|
||||
return { 'prop': prop, 'value': value }
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'direction',
|
||||
expr: /direction/im,
|
||||
action (prop, value, context) {
|
||||
return { prop, value: context.util.swapLtrRtl(value) }
|
||||
'name': 'direction',
|
||||
'expr': /direction/im,
|
||||
'action': function (prop, value, context) {
|
||||
return { 'prop': prop, 'value': context.util.swapLtrRtl(value) }
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'left',
|
||||
expr: /left/im,
|
||||
action (prop, value, context) {
|
||||
return { prop: prop.replace(this.expr, () => 'right'), value }
|
||||
'name': 'left',
|
||||
'expr': /left/im,
|
||||
'action': function (prop, value, context) {
|
||||
return { 'prop': prop.replace(this.expr, function () { return 'right' }), 'value': value }
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'right',
|
||||
expr: /right/im,
|
||||
action (prop, value, context) {
|
||||
return { prop: prop.replace(this.expr, () => 'left'), value }
|
||||
'name': 'right',
|
||||
'expr': /right/im,
|
||||
'action': function (prop, value, context) {
|
||||
return { 'prop': prop.replace(this.expr, function () { return 'left' }), 'value': value }
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'four-value syntax',
|
||||
expr: /^(margin|padding|border-(color|style|width))$/ig,
|
||||
cache: null,
|
||||
action (prop, value, context) {
|
||||
'name': 'four-value syntax',
|
||||
'expr': /^(margin|padding|border-(color|style|width))$/ig,
|
||||
'cache': null,
|
||||
'action': function (prop, value, context) {
|
||||
if (this.cache === null) {
|
||||
this.cache = {
|
||||
match: /[^\s\uFFFD]+/g
|
||||
'match': /[^\s\uFFFD]+/g
|
||||
}
|
||||
}
|
||||
|
||||
const state = context.util.guardFunctions(value)
|
||||
const result = state.value.match(this.cache.match)
|
||||
var state = context.util.guardFunctions(value)
|
||||
var result = state.value.match(this.cache.match)
|
||||
if (result && result.length === 4 && (state.store.length > 0 || result[1] !== result[3])) {
|
||||
let i = 0
|
||||
state.value = state.value.replace(this.cache.match, () => result[(4 - i++) % 4])
|
||||
var i = 0
|
||||
state.value = state.value.replace(this.cache.match, function () {
|
||||
return result[(4 - i++) % 4]
|
||||
})
|
||||
}
|
||||
|
||||
return { prop, value: context.util.unguardFunctions(state) }
|
||||
return { 'prop': prop, 'value': context.util.unguardFunctions(state) }
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'border radius',
|
||||
expr: /border-radius/ig,
|
||||
cache: null,
|
||||
flip (value) {
|
||||
const parts = value.match(this.cache.match)
|
||||
let i
|
||||
'name': 'border radius',
|
||||
'expr': /border-radius/ig,
|
||||
'cache': null,
|
||||
'flip': function (value) {
|
||||
var parts = value.match(this.cache.match)
|
||||
var i
|
||||
if (parts) {
|
||||
switch (parts.length) {
|
||||
case 2:
|
||||
i = 1
|
||||
if (parts[0] !== parts[1]) {
|
||||
value = value.replace(this.cache.match, () => parts[i--])
|
||||
value = value.replace(this.cache.match, function () {
|
||||
return parts[i--]
|
||||
})
|
||||
}
|
||||
|
||||
break
|
||||
case 3:
|
||||
// preserve leading whitespace.
|
||||
value = value.replace(this.cache.white, (m) => `${m + parts[1]} `)
|
||||
value = value.replace(this.cache.white, function (m) {
|
||||
return m + parts[1] + ' '
|
||||
})
|
||||
break
|
||||
case 4:
|
||||
i = 0
|
||||
if (parts[0] !== parts[1] || parts[2] !== parts[3]) {
|
||||
value = value.replace(this.cache.match, () => parts[(5 - i++) % 4])
|
||||
value = value.replace(this.cache.match, function () {
|
||||
return parts[(5 - i++) % 4]
|
||||
})
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return value
|
||||
},
|
||||
action (prop, value, context) {
|
||||
'action': function (prop, value, context) {
|
||||
if (this.cache === null) {
|
||||
this.cache = {
|
||||
match: /[^\s\uFFFD]+/g,
|
||||
slash: /[^/]+/g,
|
||||
white: /(^\s*)/
|
||||
'match': /[^\s\uFFFD]+/g,
|
||||
'slash': /[^\/]+/g,
|
||||
'white': /(^\s*)/
|
||||
}
|
||||
}
|
||||
|
||||
const state = context.util.guardFunctions(value)
|
||||
state.value = state.value.replace(this.cache.slash, (m) => this.flip(m))
|
||||
return { prop, value: context.util.unguardFunctions(state) }
|
||||
var state = context.util.guardFunctions(value)
|
||||
state.value = state.value.replace(this.cache.slash, function (m) {
|
||||
return this.flip(m)
|
||||
}.bind(this))
|
||||
return { 'prop': prop, 'value': context.util.unguardFunctions(state) }
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'shadow',
|
||||
expr: /shadow/ig,
|
||||
cache: null,
|
||||
action (prop, value, context) {
|
||||
'name': 'shadow',
|
||||
'expr': /shadow/ig,
|
||||
'cache': null,
|
||||
'action': function (prop, value, context) {
|
||||
if (this.cache === null) {
|
||||
this.cache = {
|
||||
replace: /[^,]+/g
|
||||
'replace': /[^,]+/g
|
||||
}
|
||||
}
|
||||
|
||||
const colorSafe = context.util.guardHexColors(value)
|
||||
const funcSafe = context.util.guardFunctions(colorSafe.value)
|
||||
funcSafe.value = funcSafe.value.replace(this.cache.replace, (m) => context.util.negate(m))
|
||||
var colorSafe = context.util.guardHexColors(value)
|
||||
var funcSafe = context.util.guardFunctions(colorSafe.value)
|
||||
funcSafe.value = funcSafe.value.replace(this.cache.replace, function (m) { return context.util.negate(m) })
|
||||
colorSafe.value = context.util.unguardFunctions(funcSafe)
|
||||
return { prop, value: context.util.unguardHexColors(colorSafe) }
|
||||
return { 'prop': prop, 'value': context.util.unguardHexColors(colorSafe) }
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'transform and perspective origin',
|
||||
expr: /(?:transform|perspective)-origin/ig,
|
||||
cache: null,
|
||||
flip (value, context) {
|
||||
'name': 'transform and perspective origin',
|
||||
'expr': /(?:transform|perspective)-origin/ig,
|
||||
'cache': null,
|
||||
'flip': function (value, context) {
|
||||
if (value === '0') {
|
||||
value = '100%'
|
||||
} else if (value.match(this.cache.percent)) {
|
||||
|
@ -323,83 +303,80 @@ module.exports = {
|
|||
} else if (value.match(this.cache.length)) {
|
||||
value = context.util.flipLength(value)
|
||||
}
|
||||
|
||||
return value
|
||||
},
|
||||
action (prop, value, context) {
|
||||
'action': function (prop, value, context) {
|
||||
if (this.cache === null) {
|
||||
this.cache = {
|
||||
match: context.util.regex(['calc', 'percent', 'length'], 'g'),
|
||||
percent: context.util.regex(['calc', 'percent'], 'i'),
|
||||
length: context.util.regex(['length'], 'gi'),
|
||||
xKeyword: /(left|right)/i
|
||||
'match': context.util.regex(['calc', 'percent', 'length'], 'g'),
|
||||
'percent': context.util.regex(['calc', 'percent'], 'i'),
|
||||
'length': context.util.regex(['length'], 'gi'),
|
||||
'xKeyword': /(left|right)/i
|
||||
}
|
||||
}
|
||||
|
||||
if (value.match(this.cache.xKeyword)) {
|
||||
value = context.util.swapLeftRight(value)
|
||||
} else {
|
||||
const state = context.util.guardFunctions(value)
|
||||
const parts = state.value.match(this.cache.match)
|
||||
var state = context.util.guardFunctions(value)
|
||||
var parts = state.value.match(this.cache.match)
|
||||
if (parts && parts.length > 0) {
|
||||
parts[0] = this.flip(parts[0], context)
|
||||
state.value = state.value.replace(this.cache.match, () => parts.shift())
|
||||
state.value = state.value.replace(this.cache.match, function () { return parts.shift() })
|
||||
value = context.util.unguardFunctions(state)
|
||||
}
|
||||
}
|
||||
|
||||
return { prop, value }
|
||||
return { 'prop': prop, 'value': value }
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'transform',
|
||||
expr: /^(?!text-).*?transform$/ig,
|
||||
cache: null,
|
||||
flip (value, process, context) {
|
||||
let i = 0
|
||||
return value.replace(this.cache.unit, (num) => process(++i, num))
|
||||
'name': 'transform',
|
||||
'expr': /^(?!text\-).*?transform$/ig,
|
||||
'cache': null,
|
||||
'flip': function (value, process, context) {
|
||||
var i = 0
|
||||
return value.replace(this.cache.unit, function (num) {
|
||||
return process(++i, num)
|
||||
})
|
||||
},
|
||||
flipMatrix (value, context) {
|
||||
return this.flip(value, (i, num) => {
|
||||
'flipMatrix': function (value, context) {
|
||||
return this.flip(value, function (i, num) {
|
||||
if (i === 2 || i === 3 || i === 5) {
|
||||
return context.util.negate(num)
|
||||
}
|
||||
return num
|
||||
}, context)
|
||||
},
|
||||
flipMatrix3D (value, context) {
|
||||
return this.flip(value, (i, num) => {
|
||||
'flipMatrix3D': function (value, context) {
|
||||
return this.flip(value, function (i, num) {
|
||||
if (i === 2 || i === 4 || i === 5 || i === 13) {
|
||||
return context.util.negate(num)
|
||||
}
|
||||
return num
|
||||
}, context)
|
||||
},
|
||||
flipRotate3D (value, context) {
|
||||
return this.flip(value, (i, num) => {
|
||||
'flipRotate3D': function (value, context) {
|
||||
return this.flip(value, function (i, num) {
|
||||
if (i === 1 || i === 4) {
|
||||
return context.util.negate(num)
|
||||
}
|
||||
|
||||
return num
|
||||
}, context)
|
||||
},
|
||||
action (prop, value, context) {
|
||||
'action': function (prop, value, context) {
|
||||
if (this.cache === null) {
|
||||
this.cache = {
|
||||
negatable: /((translate)(x|3d)?|rotate(z|y)?)$/ig,
|
||||
unit: context.util.regex(['calc', 'number'], 'g'),
|
||||
matrix: /matrix$/i,
|
||||
matrix3D: /matrix3d$/i,
|
||||
skewXY: /skew(x|y)?$/i,
|
||||
rotate3D: /rotate3d$/i
|
||||
'negatable': /((translate)(x|3d)?|rotate(z|y)?)$/ig,
|
||||
'unit': context.util.regex(['calc', 'number'], 'g'),
|
||||
'matrix': /matrix$/i,
|
||||
'matrix3D': /matrix3d$/i,
|
||||
'skewXY': /skew(x|y)?$/i,
|
||||
'rotate3D': /rotate3d$/i
|
||||
}
|
||||
}
|
||||
|
||||
const state = context.util.guardFunctions(value)
|
||||
var state = context.util.guardFunctions(value)
|
||||
return {
|
||||
prop,
|
||||
value: context.util.unguardFunctions(state, (v, n) => {
|
||||
'prop': prop,
|
||||
'value': context.util.unguardFunctions(state, function (v, n) {
|
||||
if (n.length) {
|
||||
if (n.match(this.cache.matrix3D)) {
|
||||
v = this.flipMatrix3D(v, context)
|
||||
|
@ -414,128 +391,123 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
return v
|
||||
})
|
||||
}.bind(this))
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'transition',
|
||||
expr: /transition(-property)?$/i,
|
||||
action (prop, value, context) {
|
||||
return { prop, value: context.util.swapLeftRight(value) }
|
||||
'name': 'transition',
|
||||
'expr': /transition(-property)?$/i,
|
||||
'action': function (prop, value, context) {
|
||||
return { 'prop': prop, 'value': context.util.swapLeftRight(value) }
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'background',
|
||||
expr: /(background|object)(-position(-x)?|-image)?$/i,
|
||||
cache: null,
|
||||
flip (value, context) {
|
||||
const state = util.saveTokens(value, true)
|
||||
const parts = state.value.match(this.cache.match)
|
||||
'name': 'background',
|
||||
'expr': /background(-position(-x)?|-image)?$/i,
|
||||
'cache': null,
|
||||
'flip': function (value, context) {
|
||||
var state = util.saveTokens(value, true)
|
||||
var parts = state.value.match(this.cache.match)
|
||||
|
||||
if (parts && parts.length > 0) {
|
||||
const keywords = (state.value.match(this.cache.position) || '').length
|
||||
var keywords = (state.value.match(this.cache.position) || '').length
|
||||
if (/* edge offsets */ parts.length >= 3 || /* keywords only */ keywords === 2) {
|
||||
state.value = util.swapLeftRight(state.value)
|
||||
} else {
|
||||
parts[0] = parts[0] === '0'
|
||||
? '100%'
|
||||
: (parts[0].match(this.cache.percent)
|
||||
? context.util.complement(parts[0])
|
||||
: (parts[0].match(this.cache.length)
|
||||
? context.util.flipLength(parts[0])
|
||||
: context.util.swapLeftRight(parts[0])))
|
||||
state.value = state.value.replace(this.cache.match, () => parts.shift())
|
||||
? context.util.complement(parts[0])
|
||||
: (parts[0].match(this.cache.length)
|
||||
? context.util.flipLength(parts[0])
|
||||
: context.util.swapLeftRight(parts[0])))
|
||||
state.value = state.value.replace(this.cache.match, function () { return parts.shift() })
|
||||
}
|
||||
}
|
||||
|
||||
return util.restoreTokens(state)
|
||||
},
|
||||
update (context, value, name) {
|
||||
'update': function (context, value, name) {
|
||||
if (name.match(this.cache.gradient)) {
|
||||
value = context.util.swapLeftRight(value)
|
||||
if (value.match(this.cache.angle)) {
|
||||
value = context.util.negate(value)
|
||||
}
|
||||
} else if ((context.config.processUrls === true || context.config.processUrls.decl === true) && name.match(this.cache.url)) {
|
||||
} else if (context.config.processUrls === true || context.config.processUrls.decl === true && name.match(this.cache.url)) {
|
||||
value = context.util.applyStringMap(value, true)
|
||||
}
|
||||
return value
|
||||
},
|
||||
action (prop, value, context) {
|
||||
'action': function (prop, value, context) {
|
||||
if (this.cache === null) {
|
||||
this.cache = {
|
||||
match: context.util.regex(['position', 'percent', 'length', 'calc'], 'ig'),
|
||||
percent: context.util.regex(['calc', 'percent'], 'i'),
|
||||
position: context.util.regex(['position'], 'g'),
|
||||
length: context.util.regex(['length'], 'gi'),
|
||||
gradient: /gradient$/i,
|
||||
angle: /\d+(deg|g?rad|turn)/i,
|
||||
url: /^url/i
|
||||
'match': context.util.regex(['position', 'percent', 'length', 'calc'], 'ig'),
|
||||
'percent': context.util.regex(['calc', 'percent'], 'i'),
|
||||
'position': context.util.regex(['position'], 'g'),
|
||||
'length': context.util.regex(['length'], 'gi'),
|
||||
'gradient': /gradient$/i,
|
||||
'angle': /\d+(deg|g?rad|turn)/i,
|
||||
'url': /^url/i
|
||||
}
|
||||
}
|
||||
|
||||
const colorSafe = context.util.guardHexColors(value)
|
||||
const funcSafe = context.util.guardFunctions(colorSafe.value)
|
||||
const parts = funcSafe.value.split(',')
|
||||
const lprop = prop.toLowerCase()
|
||||
var colorSafe = context.util.guardHexColors(value)
|
||||
var funcSafe = context.util.guardFunctions(colorSafe.value)
|
||||
var parts = funcSafe.value.split(',')
|
||||
var lprop = prop.toLowerCase()
|
||||
if (lprop !== 'background-image') {
|
||||
for (let x = 0; x < parts.length; x++) {
|
||||
for (var x = 0; x < parts.length; x++) {
|
||||
parts[x] = this.flip(parts[x], context)
|
||||
}
|
||||
}
|
||||
|
||||
funcSafe.value = parts.join(',')
|
||||
colorSafe.value = context.util.unguardFunctions(funcSafe, this.update.bind(this, context))
|
||||
return {
|
||||
prop,
|
||||
value: context.util.unguardHexColors(colorSafe)
|
||||
'prop': prop,
|
||||
'value': context.util.unguardHexColors(colorSafe)
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'keyword',
|
||||
expr: /float|clear|text-align/i,
|
||||
action (prop, value, context) {
|
||||
return { prop, value: context.util.swapLeftRight(value) }
|
||||
'name': 'keyword',
|
||||
'expr': /float|clear|text-align/i,
|
||||
'action': function (prop, value, context) {
|
||||
return { 'prop': prop, 'value': context.util.swapLeftRight(value) }
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'cursor',
|
||||
expr: /cursor/i,
|
||||
cache: null,
|
||||
update (context, value, name) {
|
||||
if ((context.config.processUrls === true || context.config.processUrls.decl === true) && name.match(this.cache.url)) {
|
||||
'name': 'cursor',
|
||||
'expr': /cursor/i,
|
||||
'cache': null,
|
||||
'update': function (context, value, name) {
|
||||
if (context.config.processUrls === true || context.config.processUrls.decl === true && name.match(this.cache.url)) {
|
||||
value = context.util.applyStringMap(value, true)
|
||||
}
|
||||
return value
|
||||
},
|
||||
flip (value) {
|
||||
return value.replace(this.cache.replace, (s, m) => {
|
||||
return s.replace(m, m.replace(this.cache.e, '*')
|
||||
.replace(this.cache.w, 'e')
|
||||
.replace(this.cache.star, 'w'))
|
||||
})
|
||||
'flip': function (value) {
|
||||
return value.replace(this.cache.replace, function (s, m) {
|
||||
return s.replace(m, m.replace(this.cache.e, '*').replace(this.cache.w, 'e').replace(this.cache.star, 'w'))
|
||||
}.bind(this))
|
||||
},
|
||||
action (prop, value, context) {
|
||||
'action': function (prop, value, context) {
|
||||
if (this.cache === null) {
|
||||
this.cache = {
|
||||
replace: /\b(ne|nw|se|sw|nesw|nwse)-resize/ig,
|
||||
url: /^url/i,
|
||||
e: /e/i,
|
||||
w: /w/i,
|
||||
star: /\*/i
|
||||
'replace': /\b(ne|nw|se|sw|nesw|nwse)-resize/ig,
|
||||
'url': /^url/i,
|
||||
'e': /e/i,
|
||||
'w': /w/i,
|
||||
'star': /\*/i
|
||||
}
|
||||
}
|
||||
|
||||
const state = context.util.guardFunctions(value)
|
||||
state.value = state.value.split(',')
|
||||
.map((part) => this.flip(part))
|
||||
.join(',')
|
||||
|
||||
var state = context.util.guardFunctions(value)
|
||||
var parts = state.value.split(',')
|
||||
for (var x = 0; x < parts.length; x++) {
|
||||
parts[x] = this.flip(parts[x])
|
||||
}
|
||||
state.value = parts.join(',')
|
||||
return {
|
||||
prop,
|
||||
value: context.util.unguardFunctions(state, this.update.bind(this, context))
|
||||
'prop': prop,
|
||||
'value': context.util.unguardFunctions(state, this.update.bind(this, context))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue