Начат фронтенд
This commit is contained in:
196
node_modules/autoprefixer/lib/declaration.js
generated
vendored
196
node_modules/autoprefixer/lib/declaration.js
generated
vendored
@@ -1,20 +1,81 @@
|
||||
let Browsers = require('./browsers')
|
||||
let Prefixer = require('./prefixer')
|
||||
let Browsers = require('./browsers')
|
||||
let utils = require('./utils')
|
||||
|
||||
class Declaration extends Prefixer {
|
||||
/**
|
||||
* Clone and add prefixes for declaration
|
||||
* Always true, because we already get prefixer by property name
|
||||
*/
|
||||
add(decl, prefix, prefixes, result) {
|
||||
let prefixed = this.prefixed(decl.prop, prefix)
|
||||
if (
|
||||
this.isAlready(decl, prefixed) ||
|
||||
this.otherPrefixes(decl.value, prefix)
|
||||
) {
|
||||
return undefined
|
||||
check(/* decl */) {
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Return prefixed version of property
|
||||
*/
|
||||
prefixed(prop, prefix) {
|
||||
return prefix + prop
|
||||
}
|
||||
|
||||
/**
|
||||
* Return unprefixed version of property
|
||||
*/
|
||||
normalize(prop) {
|
||||
return prop
|
||||
}
|
||||
|
||||
/**
|
||||
* Check `value`, that it contain other prefixes, rather than `prefix`
|
||||
*/
|
||||
otherPrefixes(value, prefix) {
|
||||
for (let other of Browsers.prefixes()) {
|
||||
if (other === prefix) {
|
||||
continue
|
||||
}
|
||||
if (value.includes(other)) {
|
||||
return value.replace(/var\([^)]+\)/, '').includes(other)
|
||||
}
|
||||
}
|
||||
return this.insert(decl, prefix, prefixes, result)
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Set prefix to declaration
|
||||
*/
|
||||
set(decl, prefix) {
|
||||
decl.prop = this.prefixed(decl.prop, prefix)
|
||||
return decl
|
||||
}
|
||||
|
||||
/**
|
||||
* Should we use visual cascade for prefixes
|
||||
*/
|
||||
needCascade(decl) {
|
||||
if (!decl._autoprefixerCascade) {
|
||||
decl._autoprefixerCascade =
|
||||
this.all.options.cascade !== false && decl.raw('before').includes('\n')
|
||||
}
|
||||
return decl._autoprefixerCascade
|
||||
}
|
||||
|
||||
/**
|
||||
* Return maximum length of possible prefixed property
|
||||
*/
|
||||
maxPrefixed(prefixes, decl) {
|
||||
if (decl._autoprefixerMax) {
|
||||
return decl._autoprefixerMax
|
||||
}
|
||||
|
||||
let max = 0
|
||||
for (let prefix of prefixes) {
|
||||
prefix = utils.removeNote(prefix)
|
||||
if (prefix.length > max) {
|
||||
max = prefix.length
|
||||
}
|
||||
}
|
||||
decl._autoprefixerMax = max
|
||||
|
||||
return decl._autoprefixerMax
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,10 +94,22 @@ class Declaration extends Prefixer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Always true, because we already get prefixer by property name
|
||||
* Remove visual cascade
|
||||
*/
|
||||
check(/* decl */) {
|
||||
return true
|
||||
restoreBefore(decl) {
|
||||
let lines = decl.raw('before').split('\n')
|
||||
let min = lines[lines.length - 1]
|
||||
|
||||
this.all.group(decl).up(prefixed => {
|
||||
let array = prefixed.raw('before').split('\n')
|
||||
let last = array[array.length - 1]
|
||||
if (last.length < min.length) {
|
||||
min = last
|
||||
}
|
||||
})
|
||||
|
||||
lines[lines.length - 1] = min
|
||||
decl.raws.before = lines.join('\n')
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,70 +144,17 @@ class Declaration extends Prefixer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return maximum length of possible prefixed property
|
||||
* Clone and add prefixes for declaration
|
||||
*/
|
||||
maxPrefixed(prefixes, decl) {
|
||||
if (decl._autoprefixerMax) {
|
||||
return decl._autoprefixerMax
|
||||
add(decl, prefix, prefixes, result) {
|
||||
let prefixed = this.prefixed(decl.prop, prefix)
|
||||
if (
|
||||
this.isAlready(decl, prefixed) ||
|
||||
this.otherPrefixes(decl.value, prefix)
|
||||
) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
let max = 0
|
||||
for (let prefix of prefixes) {
|
||||
prefix = utils.removeNote(prefix)
|
||||
if (prefix.length > max) {
|
||||
max = prefix.length
|
||||
}
|
||||
}
|
||||
decl._autoprefixerMax = max
|
||||
|
||||
return decl._autoprefixerMax
|
||||
}
|
||||
|
||||
/**
|
||||
* Should we use visual cascade for prefixes
|
||||
*/
|
||||
needCascade(decl) {
|
||||
if (!decl._autoprefixerCascade) {
|
||||
decl._autoprefixerCascade =
|
||||
this.all.options.cascade !== false && decl.raw('before').includes('\n')
|
||||
}
|
||||
return decl._autoprefixerCascade
|
||||
}
|
||||
|
||||
/**
|
||||
* Return unprefixed version of property
|
||||
*/
|
||||
normalize(prop) {
|
||||
return prop
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of prefixed properties to clean old prefixes
|
||||
*/
|
||||
old(prop, prefix) {
|
||||
return [this.prefixed(prop, prefix)]
|
||||
}
|
||||
|
||||
/**
|
||||
* Check `value`, that it contain other prefixes, rather than `prefix`
|
||||
*/
|
||||
otherPrefixes(value, prefix) {
|
||||
for (let other of Browsers.prefixes()) {
|
||||
if (other === prefix) {
|
||||
continue
|
||||
}
|
||||
if (value.includes(other)) {
|
||||
return value.replace(/var\([^)]+\)/, '').includes(other)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Return prefixed version of property
|
||||
*/
|
||||
prefixed(prop, prefix) {
|
||||
return prefix + prop
|
||||
return this.insert(decl, prefix, prefixes, result)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,30 +177,10 @@ class Declaration extends Prefixer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove visual cascade
|
||||
* Return list of prefixed properties to clean old prefixes
|
||||
*/
|
||||
restoreBefore(decl) {
|
||||
let lines = decl.raw('before').split('\n')
|
||||
let min = lines[lines.length - 1]
|
||||
|
||||
this.all.group(decl).up(prefixed => {
|
||||
let array = prefixed.raw('before').split('\n')
|
||||
let last = array[array.length - 1]
|
||||
if (last.length < min.length) {
|
||||
min = last
|
||||
}
|
||||
})
|
||||
|
||||
lines[lines.length - 1] = min
|
||||
decl.raws.before = lines.join('\n')
|
||||
}
|
||||
|
||||
/**
|
||||
* Set prefix to declaration
|
||||
*/
|
||||
set(decl, prefix) {
|
||||
decl.prop = this.prefixed(decl.prop, prefix)
|
||||
return decl
|
||||
old(prop, prefix) {
|
||||
return [this.prefixed(prop, prefix)]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user