Начат фронтенд
This commit is contained in:
262
node_modules/autoprefixer/lib/transition.js
generated
vendored
262
node_modules/autoprefixer/lib/transition.js
generated
vendored
@@ -79,6 +79,21 @@ class Transition {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find property name
|
||||
*/
|
||||
findProp(param) {
|
||||
let prop = param[0].value
|
||||
if (/^\d/.test(prop)) {
|
||||
for (let [i, token] of param.entries()) {
|
||||
if (i !== 0 && token.type === 'word') {
|
||||
return token.value
|
||||
}
|
||||
}
|
||||
}
|
||||
return prop
|
||||
}
|
||||
|
||||
/**
|
||||
* Does we already have this declaration
|
||||
*/
|
||||
@@ -86,6 +101,15 @@ class Transition {
|
||||
return decl.parent.some(i => i.prop === prop && i.value === value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Add declaration if it is not exist
|
||||
*/
|
||||
cloneBefore(decl, prop, value) {
|
||||
if (!this.already(decl, prop, value)) {
|
||||
decl.cloneBefore({ prop, value })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show transition-property warning
|
||||
*/
|
||||
@@ -131,123 +155,6 @@ class Transition {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all non-webkit prefixes and unprefixed params if we have prefixed
|
||||
*/
|
||||
cleanFromUnprefixed(params, prefix) {
|
||||
let remove = params
|
||||
.map(i => this.findProp(i))
|
||||
.filter(i => i.slice(0, prefix.length) === prefix)
|
||||
.map(i => this.prefixes.unprefixed(i))
|
||||
|
||||
let result = []
|
||||
for (let param of params) {
|
||||
let prop = this.findProp(param)
|
||||
let p = vendor.prefix(prop)
|
||||
if (!remove.includes(prop) && (p === prefix || p === '')) {
|
||||
result.push(param)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
cleanOtherPrefixes(params, prefix) {
|
||||
return params.filter(param => {
|
||||
let current = vendor.prefix(this.findProp(param))
|
||||
return current === '' || current === prefix
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Return new param array with different name
|
||||
*/
|
||||
clone(origin, name, param) {
|
||||
let result = []
|
||||
let changed = false
|
||||
for (let i of param) {
|
||||
if (!changed && i.type === 'word' && i.value === origin) {
|
||||
result.push({ type: 'word', value: name })
|
||||
changed = true
|
||||
} else {
|
||||
result.push(i)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Add declaration if it is not exist
|
||||
*/
|
||||
cloneBefore(decl, prop, value) {
|
||||
if (!this.already(decl, prop, value)) {
|
||||
decl.cloneBefore({ prop, value })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check property for disabled by option
|
||||
*/
|
||||
disabled(prop, prefix) {
|
||||
let other = ['order', 'justify-content', 'align-self', 'align-content']
|
||||
if (prop.includes('flex') || other.includes(prop)) {
|
||||
if (this.prefixes.options.flexbox === false) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (this.prefixes.options.flexbox === 'no-2009') {
|
||||
return prefix.includes('2009')
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Find or create separator
|
||||
*/
|
||||
div(params) {
|
||||
for (let param of params) {
|
||||
for (let node of param) {
|
||||
if (node.type === 'div' && node.value === ',') {
|
||||
return node
|
||||
}
|
||||
}
|
||||
}
|
||||
return { after: ' ', type: 'div', value: ',' }
|
||||
}
|
||||
|
||||
/**
|
||||
* Find property name
|
||||
*/
|
||||
findProp(param) {
|
||||
let prop = param[0].value
|
||||
if (/^\d/.test(prop)) {
|
||||
for (let [i, token] of param.entries()) {
|
||||
if (i !== 0 && token.type === 'word') {
|
||||
return token.value
|
||||
}
|
||||
}
|
||||
}
|
||||
return prop
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse properties list to array
|
||||
*/
|
||||
parse(value) {
|
||||
let ast = parser(value)
|
||||
let result = []
|
||||
let param = []
|
||||
for (let node of ast.nodes) {
|
||||
param.push(node)
|
||||
if (node.type === 'div' && node.value === ',') {
|
||||
result.push(param)
|
||||
param = []
|
||||
}
|
||||
}
|
||||
result.push(param)
|
||||
return result.filter(i => i.length > 0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Process transition and remove all unnecessary properties
|
||||
*/
|
||||
@@ -284,22 +191,21 @@ class Transition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if transition prop is inside vendor specific rule
|
||||
* Parse properties list to array
|
||||
*/
|
||||
ruleVendorPrefixes(decl) {
|
||||
let { parent } = decl
|
||||
|
||||
if (parent.type !== 'rule') {
|
||||
return false
|
||||
} else if (!parent.selector.includes(':-')) {
|
||||
return false
|
||||
parse(value) {
|
||||
let ast = parser(value)
|
||||
let result = []
|
||||
let param = []
|
||||
for (let node of ast.nodes) {
|
||||
param.push(node)
|
||||
if (node.type === 'div' && node.value === ',') {
|
||||
result.push(param)
|
||||
param = []
|
||||
}
|
||||
}
|
||||
|
||||
let selectors = Browsers.prefixes().filter(s =>
|
||||
parent.selector.includes(':' + s)
|
||||
)
|
||||
|
||||
return selectors.length > 0 ? selectors : false
|
||||
result.push(param)
|
||||
return result.filter(i => i.length > 0)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,6 +230,100 @@ class Transition {
|
||||
}
|
||||
return parser.stringify({ nodes })
|
||||
}
|
||||
|
||||
/**
|
||||
* Return new param array with different name
|
||||
*/
|
||||
clone(origin, name, param) {
|
||||
let result = []
|
||||
let changed = false
|
||||
for (let i of param) {
|
||||
if (!changed && i.type === 'word' && i.value === origin) {
|
||||
result.push({ type: 'word', value: name })
|
||||
changed = true
|
||||
} else {
|
||||
result.push(i)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Find or create separator
|
||||
*/
|
||||
div(params) {
|
||||
for (let param of params) {
|
||||
for (let node of param) {
|
||||
if (node.type === 'div' && node.value === ',') {
|
||||
return node
|
||||
}
|
||||
}
|
||||
}
|
||||
return { type: 'div', value: ',', after: ' ' }
|
||||
}
|
||||
|
||||
cleanOtherPrefixes(params, prefix) {
|
||||
return params.filter(param => {
|
||||
let current = vendor.prefix(this.findProp(param))
|
||||
return current === '' || current === prefix
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all non-webkit prefixes and unprefixed params if we have prefixed
|
||||
*/
|
||||
cleanFromUnprefixed(params, prefix) {
|
||||
let remove = params
|
||||
.map(i => this.findProp(i))
|
||||
.filter(i => i.slice(0, prefix.length) === prefix)
|
||||
.map(i => this.prefixes.unprefixed(i))
|
||||
|
||||
let result = []
|
||||
for (let param of params) {
|
||||
let prop = this.findProp(param)
|
||||
let p = vendor.prefix(prop)
|
||||
if (!remove.includes(prop) && (p === prefix || p === '')) {
|
||||
result.push(param)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* Check property for disabled by option
|
||||
*/
|
||||
disabled(prop, prefix) {
|
||||
let other = ['order', 'justify-content', 'align-self', 'align-content']
|
||||
if (prop.includes('flex') || other.includes(prop)) {
|
||||
if (this.prefixes.options.flexbox === false) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (this.prefixes.options.flexbox === 'no-2009') {
|
||||
return prefix.includes('2009')
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if transition prop is inside vendor specific rule
|
||||
*/
|
||||
ruleVendorPrefixes(decl) {
|
||||
let { parent } = decl
|
||||
|
||||
if (parent.type !== 'rule') {
|
||||
return false
|
||||
} else if (!parent.selector.includes(':-')) {
|
||||
return false
|
||||
}
|
||||
|
||||
let selectors = Browsers.prefixes().filter(s =>
|
||||
parent.selector.includes(':' + s)
|
||||
)
|
||||
|
||||
return selectors.length > 0 ? selectors : false
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Transition
|
||||
|
||||
Reference in New Issue
Block a user