Skip to content

Commit 354d040

Browse files
authored
Use is-vendor-prefixed and vendor-prefixes packages for better coverage (#75)
More vendor prefixes are covered in this way and it requires less self-written code to maintain.
1 parent 211bede commit 354d040

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

package-lock.json

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@
5151
"css-shorthand-expand": "^1.2.0",
5252
"css-unit-sort": "^1.1.1",
5353
"css-value-browser-h4cks-analyzer": "^1.0.1",
54+
"is-vendor-prefixed": "^1.0.0",
5455
"path": "^0.12.7",
5556
"postcss": "^7.0.2",
5657
"postcss-values-parser": "^2.0.0",
5758
"specificity": "^0.4.1",
5859
"string-natural-compare": "^2.0.3",
59-
"tinycolor2": "^1.4.1"
60+
"tinycolor2": "^1.4.1",
61+
"vendor-prefixes": "^1.0.0"
6062
},
6163
"devDependencies": {
6264
"ava": "^0.25.0",

src/analyzer/properties/prefixed.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1+
const isVendorPrefixed = require('is-vendor-prefixed')
12
const uniquer = require('../../utils/uniquer')
23

3-
const PREFIXED_REGEX = /^-(?:webkit|moz|ms|o)-/
4-
54
module.exports = properties => {
6-
const all = properties
7-
.filter(property => PREFIXED_REGEX.test(property))
5+
const all = properties.filter(isVendorPrefixed)
86

97
const share = (() => {
108
if (properties.length === 0) {

src/analyzer/values/prefixed.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
const vendorPrefixes = require('vendor-prefixes')()
12
const uniquer = require('../../utils/uniquer')
23

3-
const PREFIX_RE = /^-(?:webkit|moz|ms|o)-/i
4+
const PREFIX_REGEX = new RegExp(`^${vendorPrefixes.join('|')}`)
45

56
module.exports = values => {
6-
const all = values.filter(property => PREFIX_RE.test(property))
7+
const all = values.filter(property => PREFIX_REGEX.test(property))
78

89
const share = (() => {
910
if (values.length === 0) {

0 commit comments

Comments
 (0)